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

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

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.