How to pass variables between php scripts?

前端 未结 7 1953
梦如初夏
梦如初夏 2020-12-03 15:15

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

相关标签:
7条回答
  • 2020-12-03 15:43

    To pass info via GET:

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

    Session:

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

    Post: Take a look at this.

    0 讨论(0)
提交回复
热议问题