Using Dreamweaver MX, Iam attempting to create a login page/register page in PHP, its adding users to the mysql database, but when i add a username that already exists its supposed to divert to another page called taken.php, & also an error page when the login fails,however its still taking me to the welcome page ! whatever i do ? any thoughts ?

the login page comes back with various errors too, am i missing some important values ? the code for the login is below...

this is my first attempt, be kind !

this is the error i get back from the login.php page,

Warning: open(/tmp\sess_61267ce9f0e04fa7dcd729aaad604a4c, O_RDWR) failed: m (2) in C:\apache\htdocs\login.php on line 4

and:

Warning: open(/tmp\sess_61267ce9f0e04fa7dcd729aaad604a4c, O_RDWR) failed: m (2) in Unknown on line 0

Warning: Failed to write session data (files). Please verify that the current setting of session.save_path is correct (/tmp) in Unknown on line 0



Cheers !!

Richard.


-----------------------------------------------------------------------------------------------

<?php require_once('Connections/log.php'); ?>
<?php
// *** Start the session
session_start();
// *** Validate request to log in to this site.
$FF_LoginAction = $HTTP_SERVER_VARS['PHP_SELF'];
if (isset($HTTP_SERVER_VARS['QUERY_STRING']) && $HTTP_SERVER_VARS['QUERY_STRING']!="" ) $FF_LoginAction .= "?".$HTTP_SERVER_VARS['QUERY_STRING'];
if (isset($HTTP_POST_VARS['username'])) {
$FF_valUsername=$HTTP_POST_VARS['username'];
$FF_valPassword=$HTTP_POST_VARS['password'];
$FF_fldUserAuthorization="";
$FF_redirectLoginSuccess="welcome.html";
$FF_redirectLoginFailed="error.html";
$FF_rsUser_Source="SELECT ID, username ";
if ($FF_fldUserAuthorization != "" ) $FF_rsUser_Source .= "," . $FF_fldUserAuthorization;
$FF_rsUser_Source .= " FROM users WHERE ID='" . $FF_valUsername . "' AND username='" . $FF_valPassword . "'";
mysql_select_db($database_log, $log);
$FF_rsUser=mysql_query($FF_rsUser_Source, $log) or die(mysql_error());
$row_FF_rsUser = mysql_fetch_assoc($FF_rsUser);
if(mysql_num_rows($FF_rsUser) > 0) {
// username and password match - this is a valid user
$MM_Username=$FF_valUsername;
session_register("MM_Username" );
if ($FF_fldUserAuthorization != "" ) {
$MM_UserAuthorization=$row_FF_rsUser[$FF_fldUserAuthorization];
} else {
$MM_UserAuthorization="";
}
session_register("MM_UserAuthorization" );
if (isset($accessdenied) && false) {
$FF_redirectLoginSuccess = $accessdenied;
}
mysql_free_result($FF_rsUser);
session_register("FF_login_failed" );
$FF_login_failed = false;
header ("Location: $FF_redirectLoginSuccess" );
exit;
}
mysql_free_result($FF_rsUser);
session_register("FF_login_failed" );
$FF_login_failed = true;
header ("Location: $FF_redirectLoginFailed" );
exit;
}
?>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<form name="form1" method="POST" action="<?php echo $FF_LoginAction?>">

<table width="80%" cellspacing="0" cellpadding="0">
<tr>
<td width="11%">Username/td>
<td width="89%">
<input name="username" type="text" id="username"></td>
</tr>
<tr>
<td>Password/td>
<td>
<input name="password" type="password" id="password">
<input type="submit" name="Submit" value="Log in"></td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
</table>
</form>
</body>
</html>
Last edited by rikmg