Jump to content

PHP session variable problem


newbie8899

Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.