Just when I thought I was getting the hang of things!!!
So I added a "log in" that users have to go through in order to edit their information... It works great and redirects them to the script I posted last time. So on that page I added this to the very top of the code (so unauthenticated users could not edit):
<?
session_start();
if(!isset($myname))
{
header("location:index.php");
}
$id = $_GET["id"];
$server = "localhost";
$user = "xxx";
$pass = "xxx";
$database = "xxx";
$connection = mysql_connect($server, $user, $pass);
mysql_select_db($database, $connection);
And now I can't edit any of the form fields again. Why would this change things??
Here is the code I'm using for the login form:
<?
session_start();
if($action=="logout")
{
session_destroy();
$message = "You have successfully logged off.";
}
if(isset($submit))
{
$SQL = "SELECT username, password, id FROM employees WHERE username = '$username' AND password = '$password'";
$server = "localhost";
$user = "xxx";
$pass = "xxx";
$database = "xxx";
$connection = mysql_connect($server, $user, $pass);
mysql_select_db($database, $connection);
$result = mysql_query($SQL);
if(mysql_num_rows($result)>0)
{
$row = mysql_fetch_array($result);
$myname = $row["username"];
session_register("myname");
header("location: edit.php?id=$row[id]");
}
else
{
$action = "fail";
$message = "Your USERNAME/PASSWORD is incorrect.";
}
}
?>
<html>
<head>
<title></title>
</head>
<body>
<div align="center">
<p> </p>
<form name="login" action=index.php method=post>
<table width="100%" border="0" cellspacing="0" height="203">
<tr align="center">
<td height="240"> <br>
<br>
<? echo $message; ?>
<table width="40%" border="1" cellspacing="0" height="80" bordercolor="#0033CC">
<tr>
<td height="81">Username</td>
<td height="81">
<input type="text" name="username">
</td>
</tr>
<tr>
<td height="81">Password</td>
<td height="81">
<input type="password" name="password">
</td>
</tr>
</table>
<p>
<input type="submit" name="submit" value="Submit">
<br>
<br>
</p>
</td>
</tr>
</table>
</form>
<p> </p>
</div>
</body>
</html>