Here is the deal, I am trying to edit a row in mysql by calling data to put in form fields. It does that fine, but when I sumbit it to update the row it does not work. Not error message comes up, so I am at a loss. Can anyone help? I would be greatful and sorry the code is so long.
Also I know that all my field names are right with my DB.
here is my first page that displays current data from the DB and asks for a ID number to edit.
<?php include("startsession.php") ?>
<?php include("connection.php") ?>
<html>
<head>
<title>Oddbeat Inc. Projects</title>
<link href="styles/default.css" rel="stylesheet" type="text/css">
<?php include("header.php") ?>
</head>
<body>
<table width="700" border="1" cellpadding="10" cellspacing="0" bordercolor="#F25c03">
<tr>
<td height="508" cellpadding=20 colspan="2" bgcolor="#FFFFFF" valign=top>
<?php
if ($_SESSION['auth_level']==1){
$result = mysql_query( "SELECT * FROM users" )
or die("SELECT Error: ".mysql_error());
$num_rows = mysql_num_rows($result);
print "There are $num_rows users in the database.<P>";
print "<table width=100% border=2 align=center cellspacing=0 cellpadding=5 bordercolor='#F68423'>\n";
print "<center><tr><td>ID</td><td>First Name</td><td>Last Name</td><td>Username</td><td>Password</td><td>Access Level</td><td>Job Title</td></tr></center>\n";
while ($get_info = mysql_fetch_row($result)){
print "<tr>\n";
foreach ($get_info as $field)
print "\t<td>$field</td>\n";
print "</tr>\n";
}
print "</table>\n";
?>
<br>
<form method="POST" action="users_edit_action.php">
Enter ID Number to Edit: <input type="text" name="id" size="2"><br>
<input type="submit" value="Submit">
</form>
<?php
}
else { echo "You do not have authorisation. Please try logging in again. <a href='http://www.oddprod.com'> Login </a>";
}
?>
</td>
</tr>
<tr>
<td height="20" align="right" valign="top" background="images/footgfx3.gif" bgcolor="white">
<div align="left"> </div>
<div align="right"></div>
</td>
</tr>
</table>
</body>
<?php include("close.php") ?>
</html>
This page pulls info from the DB and puts it in the form fields (works properly)
<?php include("header.php") ?>
</head>
<body>
<table width="700" border="1" cellpadding="10" cellspacing="0" bordercolor="#F25c03">
<tr>
<td height="508" cellpadding=20 colspan="2" bgcolor="#FFFFFF" valign=top>
<?php
$id=$_POST['id'];
if ($_SESSION['auth_level']==1){
$query=" SELECT * FROM users WHERE usersID='$id'";
$result=mysql_query($query);
$num=mysql_num_rows($result);
$i=0;
while ($i < $num) {
$f_name=mysql_result($result,$i,"usersFNAME");
$l_name=mysql_result($result,$i,"usersLNAME");
$login=mysql_result($result,$i,"usersLOGIN");
$pass=mysql_result($result,$i,"usersPASS");
$titleid=mysql_result($result,$i,"usersTITLEID");
$title=mysql_result($result,$i,"usersTITLE");
?>
<table width="500" cellpadding="10" cellspacing="0" border="0">
<tr align="left" valign="top">
<td align="left" colspan="1" rowspan="1" >
<h3>Edit and Submit</h3>
<form method="post" action="users_edit_action2.php">
<input type="hidden" name="usersid" value="<? echo $id ?>">
First name: <input type="Text" name="fname" value="<? print $f_name ?>"><br>
Last name: <input type="Text" name="lname" value="<? print $l_name ?>"><br>
Login Name: <input type="Text" name="login" value="<? print $login ?>"><br>
Password: <input type="Text" name="pass" size="20" value="<? print $pass ?>"><br>
Access Level: <select name="titleid" size="1" >
<option value="<? print $titleid ?>"><? print $titleid ?></option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
</select>
1=Administrator 2=Project Manager 3=Employee<br>
Job Title: <input type="Text" name="title" value="<? print $title ?>"><br><br>
<input type="Submit" name="submit" value="Update">
</form>
</td></tr></table>
<?
++$i;
}
?>
<?php
}
else { echo "You do not have authorisation. Please try logging in again. <a href='http://www.oddprod.com'> Login </a>";
}
?>
</td>
</tr>
<tr>
<td height="20" align="right" valign="top" background="images/footgfx3.gif" bgcolor="white">
<div align="left"> </div>
<div align="right"></div>
</td>
</tr>
</table>
</body>
<?php include("close.php") ?>
</html>
This page takes any changes from the form and updates the DB. (It does not work properly)
<?php include("startsession.php") ?>
<?php include("connection.php") ?>
<html>
<head>
<title>Oddbeat Inc. Projects</title>
<link href="styles/default.css" rel="stylesheet" type="text/css">
<?php include("header.php") ?>
</head>
<body>
<table width="700" border="1" cellpadding="10" cellspacing="0" bordercolor="#F25c03">
<tr>
<td height="508" cellpadding=20 colspan="2" bgcolor="#FFFFFF" valign=top>
<?php
if ($_SESSION['auth_level']==1){
$id=$_POST['usersid'];
$fname=$_POST['fname'];
$lname=$_POST['lname'];
$login=$_POST['login'];
$pass=$_POST['pass'];
$titleid=$_POST['titleid'];
$title=$_POST['title'];
mysql_query(" UPDATE users SET usersFNAME='$fname' , usersLNAME='$lname', usersLOGIN='$login', usersPASS='$pass', usersTITLEID='$titleid', usersTITLE='$title', WHERE usersID=$id");
echo "User Updated. <a href='users_edit.php'>Edit another user.</a>";
?>
<?php
}
else { echo "You do not have authorisation. Please try logging in again. <a href='http://www.oddprod.com'> Login </a>";
}
?>
</td>
</tr>
<tr>
<td height="20" align="right" valign="top" background="images/footgfx3.gif" bgcolor="white">
<div align="left"> </div>
<div align="right"></div>
</td>
</tr>
</table>
</body>
<?php include("close.php") ?>
</html>
Again I am sorry the code is so long, but I do not have anyone in person to help me, because no one knows PHP around here.