Session problem?
i've got the following error :
Warning: session_start(): open(/tmp\sess_b44ffdfc75e9ae187cb49d968c8db84a, O_RDWR) failed: No such file or directory (2) in c:\inetpub\wwwroot\project\auth_user.php on line 2
Warning: session_start(): Cannot send session cookie - headers already sent by (output started at c:\inetpub\wwwroot\project\auth_user.php:2) in c:\inetpub\wwwroot\project\auth_user.php on line 2
Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at c:\inetpub\wwwroot\project\auth_user.php:2) in c:\inetpub\wwwroot\project\auth_user.php on line 2
Warning: Unknown(): open(/tmp\sess_b44ffdfc75e9ae187cb49d968c8db84a, O_RDWR) failed: No such file or directory (2) in Unknown on line 0
Warning: Unknown(): Failed to write session data (files). Please verify that the current setting of session.save_path is correct (/tmp) in Unknown on line 0
below are my code. Please help me! What's wrong with it?
<?php
session_start();
include "common_db.inc";
function auth_user($userid, $userpassword)
{
$query = "SELECT username FROM $user_tablename WHERE username = '$userid' AND password = password('$userpassword')";
$result = mysql_query($query);
if(!mysql_num_rows($result)) return 0;
else
{
$query_data = mysql_fetch_row($result);
return $query_data[0];
}
}
function login_form( )
{
global $PHP_SELF;
?>
<HTML>
<HEAD><TITLE>Login</TITLE></HEAD>
<BODY><FORM METHOD="POST" ACTION="<? echo $PHP_SELF ?>">
<DIV ALIGN="CENTER"><CENTER>
<H3>Please log in to access the page you requested.</H3>
<TABLE BORDER="1" WIDTH="200" CELLPADDING="2">
<TR>
<TH WIDTH="18%" ALIGN="RIGHT" NOWRAP>ID</TH>
<TD WIDTH="82%" NOWRAP> <INPUT TYPE="TEXT" NAME="userid" SIZE="8"> </TD>
</TR>
<TR>
<TH WIDTH="18%" ALIGN="RIGHT" NOWRAP>Password</TH>
<TD WIDTH="82%" NOWRAP>
<INPUT TYPE="PASSWORD" NAME="userpassword" SIZE="8"> </TD>
</TR>
<TR>
<TD WIDTH="100%" COLSPAN="2" ALIGN="CENTER" NOWRAP>
<INPUT TYPE="SUBMIT" VALUE="LOGIN" NAME="Submit"> </TD>
</TR>
</TABLE>
</CENTER></DIV>
</FORM>
</BODY>
</HTML>
<?
}
if(!isset($userid))
{ login_form();
exit;
}
else
{
session_register("userid", "userpassword");
$username = auth_user($userid, $userpassword);
if(!$username)
{
session_unregister("userid");
session_unregister("userpassword");
echo "Authorization failed. " .
"You must enter a valid userid and password combo. " .
"Click on the following link to try again.<BR>\n";
echo "<A HREF=\"$PHP_SELF\">Login</A><BR>";
exit;
}
else
echo "Welcome, $username!";
}
?>
|