Login Page $_SESSION
Posted: Fri Jul 09, 2004 9:44 pm
I just switched from using session_register() to $_SESSION and am having difficulties.
This is my login page script ... I think something is wrong with the setting sessions function. THANKS!
This is my login page script ... I think something is wrong with the setting sessions function. THANKS!
Code: Select all
<?php
include("includes/config.php");
$connection = mysql_connect($hostname, $user, $pass) or die ("Unable to connect to MySQL Database!");
$query = "SELECT * FROM accounts WHERE login = '$uname' AND password = PASSWORD('$upassword')";
$result = mysql_db_query($database, $query, $connection);
if (mysql_num_rows($result) == 1)
{
session_name("wdaccounts");
session_start();
$_SESSION['client_id'] = $clientid;
$_SESSION['client_name'] = $name;
$_SESSION['client_login'] = $login;
if ($uname == admin)
{
header("Location: admin.php");
}
else
{
header("Location: client.php");
}
mysql_free_result ($result);
mysql_close($connection);
}
else
{
echo "<center><font face=verdana>Login Error. Either you haven't logged in, or the Username/Password you entered were incorrect.</font></center><br><br>";
mysql_free_result ($result);
mysql_close($connection);
login_page();
exit;
}
function login_page()
{
?>
<html>
<title>WDAccounts Login</title>
<body>
<form ACTION="<?=$_SERVER['PHP_SELF'];?>" method="POST"> <center>
<TABLE align=center cellSpacing=1 cellPadding=1 width="40%" border=2 bordercolor=#929bab>
<TR>
<TD style="PADDING-LEFT: 10px; WIDTH: 33%; COLOR: #ffffff; BACKGROUND-COLOR:#929bab"><B>User name</B></TD>
<TD><input type="text" name="uname" value="" size="20" maxlength="60"></TD>
</TR>
<TR>
<TD style="PADDING-LEFT: 10px; WIDTH: 33%; COLOR: #ffffff; BACKGROUND-COLOR:#929bab"><B>Password</B></TD>
<TD><input type="password" name="upassword" size="20"></TD></TR>
</TABLE>
<center><input name="submit" type="submit" value="Submit" /> </center>
</form>
</center>
</body>
</html>
<?php
}
?>