Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End How do I send a PHP variable to another file.

  • This topic is empty.
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #24912
    mattvot
    Member

    How would I send a php variable to another php file and then redirect the user to a totaly different file?

    #57928
    "mattvot" wrote:
    How would I send a php variable to another php file?

    You don’t really send variables in php. If you include another php file, the included file will have access to all global variables.

    If you want to keep the value of some variable between page requests then you will need to store the value somewhere. The easiest places to store values are in cookies, sessions or a database. Which one you use depends on the exact scenario.

    http://www.w3schools.com/PHP/php_includes.asp
    http://www.w3schools.com/PHP/php_sessions.asp

    #57994
    Chris Coyier
    Keymaster

    Or, you can POST or GET the variable over.

    Like when you see something like http://example.com/?var=123

    That is available through a GET on another PHP file as a way to pass variables back and forth.

    #57991
    mattvot
    Member

    So, how would would I POST it, without creating a new form?

    Basically, the original issue I needed this for is solved. I tried sessions, but that was to confusing, and there were security issues, so I opted for cookies instead.

    But never-the-less, I am intrigued on how you would send a POST variable over to another php file without a form by actually POSTing it, if it is even possible?.

    (p.s. It’s a shameful plug, i know :) but the site this thread was going to help is now completed. http://www.phpyouradmin.com/)

    #58003
    AshtonSanders
    Participant
    "mattvot" wrote:
    So, how would would I POST it, without creating a new form?

    PHP cURL:

    I would learn sessions first though, as it’s about 1/3 as complicated… I don’t fully know cURL; I just hack my way through it when I need to. Lots of guessing and checking.

Viewing 5 posts - 1 through 5 (of 5 total)
  • The forum ‘Back End’ is closed to new topics and replies.