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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.