Jump to content


Photo

PHP Login Script Problem


  • Please log in to reply
3 replies to this topic

#1 columbo1977

columbo1977
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 05 May 2006 - 09:43 AM

Hi

I am new to this and I am trying to get a login PHP script right, when i run the site in my testing server and i goto the login page i get the following error :

Warning: open(/tmp\sess_8624c9e01e8a8248449ffb495f6be885, O_RDWR) failed: No such file or directory (2) in c:\webserver\phpdev5\www\ccc_website\login.php on line 5

does anyone know why this is happening, as i want to get the login system working on the site. Sorry if this is a simple problem but i am new to this.

Please see below for the code.

Thanks

Columbo1977

<?php require_once('Connections/DB.php'); ?>
<?php
// *** Validate request to login to this site.
if (!isset($_SESSION)) {
session_start();
}

$loginFormAction = $_SERVER['PHP_SELF'];
if (isset($_GET['accesscheck'])) {
$_SESSION['PrevUrl'] = $_GET['accesscheck'];
}

if (isset($_POST['username'])) {
$loginUsername=$_POST['username'];
$password=$_POST['password'];
$MM_fldUserAuthorization = "";
$MM_redirectLoginSuccess = "members/members.htm";
$MM_redirectLoginFailed = "denied.html";
$MM_redirecttoReferrer = false;
mysql_select_db($database_DB, $DB);

$LoginRS__query=sprintf("SELECT Username, password FROM users WHERE Username='%s' AND password='%s'",
get_magic_quotes_gpc() ? $loginUsername : addslashes($loginUsername), get_magic_quotes_gpc() ? $password : addslashes($password));

$LoginRS = mysql_query($LoginRS__query, $DB) or die(mysql_error());
$loginFoundUser = mysql_num_rows($LoginRS);
if ($loginFoundUser) {
$loginStrGroup = "";

//declare two session variables and assign them
$_SESSION['MM_Username'] = $loginUsername;
$_SESSION['MM_UserGroup'] = $loginStrGroup;

if (isset($_SESSION['PrevUrl']) && false) {
$MM_redirectLoginSuccess = $_SESSION['PrevUrl'];
}
header("Location: " . $MM_redirectLoginSuccess );
}
else {
header("Location: ". $MM_redirectLoginFailed );
}
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><!-- InstanceBegin template="/Templates/Template_new.dwt" codeOutsideHTMLIsLocked="false" -->
<head>
<!-- InstanceBeginEditable name="doctitle" -->
<title>Chief's Computer Club</title>
<!-- InstanceEndEditable -->
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script language="JavaScript" type="text/JavaScript">
<!--

function MM_reloadPage(init) { //reloads the window if Nav4 resized
if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function MM_findObj(n, d) { //v4.01
var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_showHideLayers() { //v6.0
var i,p,v,obj,args=MM_showHideLayers.arguments;
for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
obj.visibility=v; }
}
//-->
</script>
<!-- InstanceBeginEditable name="head" --><!-- InstanceEndEditable -->
</head>

<body bgcolor="#999999" text="#000000" link="#0000FF" vlink="#0000FF" alink="#0000FF" leftmargin="0" topmargin="0" onLoad="MM_showHideLayers('Profiles','','hide');MM_showHideLayers('Links','','hide');MM_showHideLayers('Cinema','','hide');MM_showHideLayers('News','','hide');MM_showHideLayers('attractions','','hide')">
<table width="100%" border="0">
<tr>
<td><div align="center"><font color="#0066CC" size="7"> Chief's Computer Club</font></div></td>
</tr>
<tr>
<td><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="120" nowrap onMouseOver="MM_showHideLayers('attractions','','show')" onMouseOut="MM_showHideLayers('attractions','','hide')">
<div align="center"> <a href="news.htm"><font color="#0000FF">News</font></a>
</div></td>
<td width="120" nowrap onMouseOver="MM_showHideLayers('News','','show')" onMouseOut="MM_showHideLayers('News','','hide')">
<div align="center"><a href="#"><font color="#0000FF">Downloads</font></a>
</div></td>
<td width="120" nowrap onMouseOver="MM_showHideLayers('Cinema','','show')" onMouseOut="MM_showHideLayers('Cinema','','hide')">
<div align="center"><a href="#"><font color="#0000FF">Newsletters</font></a>
</div></td>
<td width="120" nowrap onMouseOver="MM_showHideLayers('Profiles','','show')" onMouseOut="MM_showHideLayers('Profiles','','hide')">
<div align="center"><a href="#"><font color="#0000FF">Tutorials</font></a>
</div></td>
<td width="120" nowrap onMouseOver="MM_showHideLayers('Links','','show')" onMouseOut="MM_showHideLayers('Links','','hide')">
<div align="center"><a href="#"><font color="#0000FF">Advice</font></a>
</div></td>
</tr>
</table></td>
</tr>
</table>
<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="15" height="23"> <p><img src="images/shim.gif" width="13" height="8"></p>

</td>
<td width="128">
<p>&nbsp;</p>
</td>
<td width="15"><img src="images/shim.gif" width="15" height="5"></td>
<td width="100%">&nbsp;</td>
<td width="15"><img src="images/shim.gif" width="15" height="5"></td>
<td width="116">&nbsp;</td>
<td width="15"><img src="images/shim.gif" width="15" height="5"></td>
</tr>
<tr>
<td width="15">&nbsp;</td>
<td valign="top">
<table width="145" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="128" height="20" valign="top" background="images/background_blue.jpg" bgcolor="#999999"><div align="center"><font color="#FFFFFF">Menu</font></div></td>
</tr>
<tr>
<td height="171" background="images/background_grey_fullscreen.jpg" bgcolor="#999999">
<p><a href="index.html">Home</a></p>
<p><font color="#000000"><a href="meetings.htm"><font color="#0000FF">Meeting
Dates </font></a><font color="#0000FF"><br>
<br>
</font></font><a href="aboutme.htm"><font color="#0000FF">About
Me </font></a><font color="#000000"><font color="#0000FF"><br>
<br>
</font></font><a href="links.htm"><font color="#0000FF">Links</font></a></p>
<p><font color="#000000"><a href="contact.htm">Contact Us</a><br>
<br>
</font> </p>
</td>
</tr>
</table>
<table width="145" border="0" cellpadding="0" cellspacing="0" bgcolor="#999999">
<tr>
<td width="128" background="images/background_blue.jpg" bgcolor="#999999"><div align="center"><font color="#FFFFFF">Login</font></div></td>
</tr>
<tr>
<td valign="top" background="images/background_grey_fullscreen.jpg" bgcolor="#999999">
<p align="center"><font color="#0000FF"><br>
<a href="login.php">Login Page</a></font></p>
<p align="center"><font color="#000000"><a href="registration.php"><font color="#0000FF">New
User Signup</font></a></font></p>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><p><font color="#000000">You are visitor number :</font></p>
<p>&nbsp;</p></td>
</tr>
</table>
<p align="left"><font color="#000000"><br>
</font><br>
</p>
</td>
</tr>
</table></td>
<td width="15">&nbsp;</td>
<td valign="top"> <!-- InstanceBeginEditable name="Main" -->
<table width="100%" height="98%" border="0" cellpadding="0" cellspacing="0" bordercolor="#999999" background="images/background_grey_fullscreen.jpg">
<tr>
<td width="100%" height="9%" bgcolor="#999999"> <div align="center"><strong><font size="6">Login
Page </font></strong></div></td>
<td>&nbsp;</td>
</tr>
<tr>
<td height="398" valign="top" bgcolor="#999999"> <div align="center">
<p>Enter your Username and Password below to enter the members area
of the website</p>
<form ACTION="<?php echo $loginFormAction; ?>" name="form1" method="POST">
<table width="100%" border="1">
<tr>
<td width="50%">Username</td>
<td><input name="username" type="text" id="username"></td>
</tr>
<tr>
<td width="50%">Password</td>
<td><input name="password" type="password" id="password"></td>
</tr>
<tr>
<td width="50%"><div align="center">
<input type="submit" name="Submit" value="Login">
</div></td>
<td><div align="center">
<input type="reset" name="Submit5" value="Reset">
</div></td>
</tr>
</table>
</form>
<p>&nbsp;</p>
</div></td>
<td> <p>&nbsp;</p></td>
</tr>
</table>
<!-- InstanceEndEditable --></td>
<td width="15">&nbsp;</td>
<td valign="top">
<table width="156" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="128" background="images/background_blue.jpg" bgcolor="#999999"><div align="center"><font color="#FFFFFF">Search</font></div></td>
</tr>
<tr>
<td width="128" height="177" valign="top" background="images/background_grey_fullscreen.jpg">
<p align="center"><font color="#000000">Search The Site :<br>
<input type="text" name="textfield3">
<input type="submit" name="Submit3" value="Search">
</font></p>
<form name="form6" method="post" action="">
<div align="center"> </div>
</form>
<form name="form3" method="post" action="">
</form>
<p align="center"><font color="#000000">Search The Internet<br>
<input type="text" name="textfield4">
<input type="submit" name="Submit4" value="Search">
</font></p>
<form name="form7" method="post" action="">
</form>
<form name="form4" method="post" action="">
</form>

</td>
</tr>
</table>
<table width="145" height="360" border="0" cellpadding="0" cellspacing="0">
<tr>
<td background="images/background_blue.jpg"><div align="center"><font color="#FFFFFF">Signup</font></div></td>
</tr>
<tr>
<td height="207" background="images/background_grey_fullscreen.jpg">
<p><font color="#000000">Newsletter<br>
<font size="2">Please enter E-Mail address</font></font></p>
<form name="form5" method="post" action="">
<div align="center">
<input type="text" name="textfield5">
<br>
<input type="submit" name="Submit2" value="Submit">
</div>
</form>
<p align="center"><font color="#000000"> ------------------------<br>
<font color="#0000FF" size="4">Image Of The Month</font><br>
<a href="images/Computer_sq.jpg"><img src="images/Computer_sq.jpg" alt="" name="Advert" width="155" height="156" border="0"></a>
</font></p>
</td>
</tr>
</table> </td>
<td width="15">&nbsp;</td>
</tr>
</table>
</body>
<!-- InstanceEnd --></html>

#2 prodynetech

prodynetech
  • New Members
  • Pip
  • Newbie
  • 4 posts

Posted 06 May 2006 - 04:33 AM

The problem is not with your login scripts (as far as I can tell). The problem is either with DB.php or how you handle the sessions. From the warning you are getting I am assuming that you have created custom session handlers that store sessions in files.

Your code is unable to open/create the session file (cache) because the file path is incorrect. If you are running on a windows system then the "/tmp" needs to be changed to "\tmp" or "C:\tmp". If you are running on a Linux box you need to change the session filename from "\sess_xxxxxxxxxxxxx" to "/sess_xxxxxxxxx".

Very simple to do this. You just need to call session_save_path( $path ) ; where $path is the path to the temp dir (that must have read-write-execute priviledges) where the session file will be created.

If you are still having problems let me know. I have some nifty session handling classes you can try out.

Best Regards,

ProdyneTech

[!--quoteo(post=371481:date=May 5 2006, 05:43 AM:name=columbo1977)--][div class=\'quotetop\']QUOTE(columbo1977 @ May 5 2006, 05:43 AM) View Post[/div][div class=\'quotemain\'][!--quotec--]
Hi

I am new to this and I am trying to get a login PHP script right, when i run the site in my testing server and i goto the login page i get the following error :

Warning: open(/tmp\sess_8624c9e01e8a8248449ffb495f6be885, O_RDWR) failed: No such file or directory (2) in c:\webserver\phpdev5\www\ccc_website\login.php on line 5

does anyone know why this is happening, as i want to get the login system working on the site. Sorry if this is a simple problem but i am new to this.

Please see below for the code.

Thanks

Columbo1977
[/quote]


#3 columbo1977

columbo1977
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 06 May 2006 - 05:14 PM

Hi, where di i put that in my code?

Thanks

Columbo1977

#4 prodynetech

prodynetech
  • New Members
  • Pip
  • Newbie
  • 4 posts

Posted 08 May 2006 - 08:14 PM

You need to call set_save_path( $path ) before you call session_start( ).




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users