ive had php installed and set up for some time with apache and mysql on my localhost. But ive come to using sessionsin php, and, well, they work fine on my server but not on my localhost!
Ive read through numerous posts on the internet with no luck. I dont suppose anyone else has a solution to this problem, or is having the same problem?
Ive tried settings the session.save_path = c:\php\sessiondata in the php.ini file, and i now know that the sessions are being written and created in this directory. But the problem comes when i try and use a login form which i know already works. This is the code im susing incase anyone wants to check it out:
index.php
Code: Select all
<?
include "emailconfig.php";
if(isset($username)) {
mysql_connect($db_host, $db_username, $db_passwd);
@mysql_select_db("$db_name") or die ("Unable to select database");
$password = md5($password);
$query = "Select * from $db_authtable where $db_usernamefield = '$username' and $db_passwordfield = '$password'";
$res = mysql_query($query);
if(@mysql_num_rows($res) < 1) {
echo "<center><b><font size=2 color="#cc0000">Sorry, Invalid username/password!</font></b></center>";
} else {
$row = mysql_fetch_array($res);
$uid = $row[$db_userid];
session_register(uid);
if ($uid == "admin") {
header("Location: adminindex.php");
exit();
} else {
header("Location: mailbox.php");
exit();
}
}
}
?>
<html>
<link href="style.css" rel="stylesheet" type="text/css">
<body>
<div align="center">
<p>E-mail Login</p>
<form name="form1" method="post" action="index.php">
<table width="100%" border="1" bordercolor="<? echo "$bcolour" ?>">
<tr>
<td width="50%"><div align="right"><p><b>Username: </b></p></div></td>
<td width="50%"><div align="left">
<input name="username" type="text" class="formboxes" id="username">
</div></td>
</tr>
<tr>
<td><div align="right"><p><b>Password: </b></p></div></td>
<td><div align="left">
<input name="password" type="password" class="formboxes" id="password">
</div></td>
</tr>
<tr>
<td colspan="2"><div align="center">
<input name="Enter" type="submit" class="formboxes" id="Enter" value="Enter">
</div></td>
</tr>
</table>
</form>
</div>
</body>
</html>Code: Select all
<link href="style.css" rel="stylesheet" type="text/css">
<?
include "emailconfig.php";
include "adminheader.php";
echo "<br><p><b>Welcome, Admin.</b></p><br><p>Please use the menu above to make any necessary changes.</p>";
?>Code: Select all
<?
include "emailconfig.php";
global $uid, $db_host,$db_username,$db_passwd,$db_name;
session_start();
if(!isset($uid)) {
header("Location: index.php");
exit();
}
mysql_connect($db_host, $db_username, $db_passwd);
@mysql_select_db("$db_name") or die ("Unable to select database");
//error_reporting(E_ALL & ~E_NOTICE & ~E_WARNING);
?>
<html>
<title>Mail Box</title>
<link rel="stylesheet" TYPE="text/css" HREF="style.css">
<body>
<tr><td><tr><td><span class="box"><table width=100% border="1" align=center bordercolor="<? echo $bcolour ?>">
<tr class="bg2">
<td width=16% align=center><a href="adduser.php">Add User </a></td>
<td width=16% align=center class=""><a href="edituser.php">Edit User </a></td>
<td width=16% align=center class=""><a href="deleteuser.php">Delete User</a></td>
<td width=16% align=center class="normal"><a href="account.php">Account</a></td>
<td width=16% align=center class=""><a href="logout.php">Logout</a></td>
</tr>
</table>
</span>
</body>
</html>Code: Select all
<?
if(!isset($uid)) {
header("Location: index.php");
exit();
}
?>thanks
Andy Burton
?>