newbie8899 Posted April 16, 2008 Share Posted April 16, 2008 Hi, all, I have a problem here.. for example in the first page - page1.php, i have a form. The form have LoginID and Pwd. when i click at the submit button, it will collect the LoginID and Pwd into the session variable.. then will link to page2.php. The problem i face now is i cannot get the session variable in page2.php.. below is my code. <?php session_start(); // start up your PHP session! $_SESSION["LoginID"] = $_REQUEST["LoginID"]; $_SESSION["Pwd"] = $_REQUEST["Pwd"]; ?> <form name="form1" action="page2.php" method="POST"> <table> <tr> <td>Login ID:</td><td><input name="LoginID" type="text" id="LoginID" size="20" </td> </tr> <tr> <td>Password:</td><td><input name="Pwd" type="text" id="Pwd" size="20" </td> </tr> <tr> <td><input name="submit" type="submit" id="submit" size="20" </td> </tr> </form> Then in the second page, page2.php i do this: <?php session_start(); echo $_SESSION[‘LoginID]; echo $_SESSION[‘Pwd]; ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>Untitled Document</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head> <body> </body> </html> but the session variable it got is empty.. anyone.. please help.. thank you in advance. Link to comment https://forums.phpfreaks.com/topic/101330-php-session-variable-problem/ Share on other sites More sharing options...
wmguk Posted April 16, 2008 Share Posted April 16, 2008 you only have one ' try <?php session_start(); echo $_SESSION['LoginID']; echo $_SESSION['Pwd']; ?> Link to comment https://forums.phpfreaks.com/topic/101330-php-session-variable-problem/#findComment-518292 Share on other sites More sharing options...
newbie8899 Posted April 16, 2008 Author Share Posted April 16, 2008 Sorry, actually that is typo.. in my coding it is ''.. but it doesnt work. Link to comment https://forums.phpfreaks.com/topic/101330-php-session-variable-problem/#findComment-518302 Share on other sites More sharing options...
Cep Posted April 16, 2008 Share Posted April 16, 2008 Your setting the values of the session variables from request variables that have not even been referenced or passed a value themselves. That is the problem. Link to comment https://forums.phpfreaks.com/topic/101330-php-session-variable-problem/#findComment-518306 Share on other sites More sharing options...
newbie8899 Posted April 16, 2008 Author Share Posted April 16, 2008 oo..i know what u mean.. thanks thanks.. is working now.. thanks a lot. Link to comment https://forums.phpfreaks.com/topic/101330-php-session-variable-problem/#findComment-518312 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.