I am having problems getting the $_SESSION to set, the $_SESSION will work fine when its first gets the value, however, when I go to another page, the $_SESSION then loses its value. So if any one can take a look at my code and see if there is any problems, that would be good.
Thanks
Here is my code
[PHP]
<?php if (!isset($_SESSI ON))
session_start() ;
$loginFormActio n = $_SERVER['PHP_SELF'];
if (isset($_POST['txtUserName']))
{
mysql_select_db ($database_con, $con);
$LoginRS = mysql_query("SE LECT * FROM User WHERE passwd='".$_POS T['txtPassword']."' AND login='".$_POST['txtUserName']."'" , $con or die(mysql_error ());
$row_loginFound User = mysql_fetch_ass oc($LoginRS);
$loginFoundUser = mysql_num_rows( $LoginRS);
if ($loginFoundUse r > 0)
{
//declare three session variables and assign them
$_SESSION['conUserID'] = $row_loginFound User['UserID'];
$_SESSION['UserEMail'] = $row_loginFound User['Email'];
$_SESSION['UserName'] = $row_loginFound User['FName']." ".$row_loginFou ndUser['LName'];
}//end of if
}//end of if ?>
<form action="<?php echo $loginFormActio n; ?>" method="post" name="frmLogin" id="frmLogin">
<table border="0" cellpadding="0" cellspacing="0" >
<tr>
<td align="left">
<br/><label>My Business Continuity <br />Plans</label>
</td>
</tr>
<?php //checks if the user log in
if (isset($_SESSIO N['conUserID']))
{
echo "<tr>
<td align=\"left\">
<a href=\"Page2.ph p?UserID=".$_SE SSION['conUserID']."\">Go To Page 2</a>
<br/><br/>
</td>
</tr>
</td></tr>";
}//end of if
else
{
echo "<tr>
<td>
<label>User Name:</label>
</td>
</tr>
<tr>
<td>
<input name=\"txtUserN ame\" type=\"text\" id=\"txtUserNam e\" />
</td>
</tr>
<tr>
<td>
<label>Password :</label>
</td>
</tr>
<tr>
<td>
<input name=\"txtPassw ord\" type=\"password \" id=\"txtPasswor d\" />
</td>
</tr>";
}//end of else?>
</table>[/PHP]
Thanks
Here is my code
[PHP]
<?php if (!isset($_SESSI ON))
session_start() ;
$loginFormActio n = $_SERVER['PHP_SELF'];
if (isset($_POST['txtUserName']))
{
mysql_select_db ($database_con, $con);
$LoginRS = mysql_query("SE LECT * FROM User WHERE passwd='".$_POS T['txtPassword']."' AND login='".$_POST['txtUserName']."'" , $con or die(mysql_error ());
$row_loginFound User = mysql_fetch_ass oc($LoginRS);
$loginFoundUser = mysql_num_rows( $LoginRS);
if ($loginFoundUse r > 0)
{
//declare three session variables and assign them
$_SESSION['conUserID'] = $row_loginFound User['UserID'];
$_SESSION['UserEMail'] = $row_loginFound User['Email'];
$_SESSION['UserName'] = $row_loginFound User['FName']." ".$row_loginFou ndUser['LName'];
}//end of if
}//end of if ?>
<form action="<?php echo $loginFormActio n; ?>" method="post" name="frmLogin" id="frmLogin">
<table border="0" cellpadding="0" cellspacing="0" >
<tr>
<td align="left">
<br/><label>My Business Continuity <br />Plans</label>
</td>
</tr>
<?php //checks if the user log in
if (isset($_SESSIO N['conUserID']))
{
echo "<tr>
<td align=\"left\">
<a href=\"Page2.ph p?UserID=".$_SE SSION['conUserID']."\">Go To Page 2</a>
<br/><br/>
</td>
</tr>
</td></tr>";
}//end of if
else
{
echo "<tr>
<td>
<label>User Name:</label>
</td>
</tr>
<tr>
<td>
<input name=\"txtUserN ame\" type=\"text\" id=\"txtUserNam e\" />
</td>
</tr>
<tr>
<td>
<label>Password :</label>
</td>
</tr>
<tr>
<td>
<input name=\"txtPassw ord\" type=\"password \" id=\"txtPasswor d\" />
</td>
</tr>";
}//end of else?>
</table>[/PHP]
Comment