Pass a variable form one php file to another - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Pass a variable form one php file to another

dustinrdustinr Posts: 3Member
I have created a php file that generates a number lets call it refno. What I want to do is pass "refno" to a second php file and display the number to the screen.
Any ideas?

Comments

  • DarQDarQ Posts: 1,625Member
    : I have created a php file that generates a number lets call it refno. What I want to do is pass "refno" to a second php file and display the number to the screen.
    : Any ideas?
    :
    look php.net for sessions,

    if you use session_start() at the beginning of EVERY script (at least those where you want the vars) and then you have a global array called $_SESSION.
    scripta:
    session_start();
    $_SESSION['var'] = 'blaat';

    scriptb:
    session_start();
    echo $_SESSION['var'];

    and you should see blaat echoed.


    [size=5][italic][blue]Dar[RED]Q[/RED][/blue][/italic][/size]
    NEW url--> http://mark.space.servehttp.com

  • fnoyanfnoyan Posts: 103Member
    : I have created a php file that generates a number lets call it refno. What I want to do is pass "refno" to a second php file and display the number to the screen.
    : Any ideas?
    :

    you can use cookie's and also pass any variable from one file to another. you can use
    but you must use a form to send the variables.

  • emperoremperor Posts: 59Member
    : I have created a php file that generates a number lets call it refno. What I want to do is pass "refno" to a second php file and display the number to the screen.
    : Any ideas?
    :

    if the first script displays a link to the second, you can put it in the query string, ie in script 1 the link would look like this:
    [code]echo "script 2";[/code]
    then script 2 would just have
    [code]echo "Number: $_GET[refno]";[/code]
Sign In or Register to comment.