Erogol Erogol - 9 months ago 50
PHP Question

How to pass variables between php scripts?

Is there any way to pass values and variables between php scripts?

Formally, I tried to code a login page and when user enter wrong input first another script will check the input and if it is wrong, site returns to the last script page and show a warning like "It is wrong input". For this aim, I need to pass values from scripts I guess.

Regards... :P

Answer Source

To pass info via GET:

    header('Location: otherScript.php?var1=val1&var2=val2');


    // first script
    $_SESSION['varName'] = 'varVal';
    header('Location: second_script.php'); // go to other

    // second script
    $myVar = $_SESSION['varName'];

Post: Take a look at this.