Hello there. I used this code for user and it works but when I use and alter a bit for admin side system, there is no data inside of the text field and the username keep on changing to 0 eventhough I type in other username. This is the code.
password.php
<?php
session_start();
$admin=$_POST['admin_id'];
$adpass=$_POST['admin_password'];
$conn = mysql_connect("localhost", "root", "")or die("Could not connect to server");
$db = mysql_select_db("Smartlocker", $conn)or die("Could not connect to database");
$sql = "SELECT * FROM admin WHERE admin_id='$admin' ";
$result = mysql_query($sql) or die ("Could not execute query");
$info=mysql_fetch_row($result);
?>
<?php
do{
echo "
<table width='172' border='0'>
<tr>
<td width='62' height='32'><i><b>Username</b></i></td>
<td width='10'><strong>:</strong></td>
<td width='100'><input name='admin_id' type='text' size='30' value='$info[0]'></td>
</tr>
<tr>
<td width='62' height='30'><i><b>Password</b></i></td>
<td width='10'><strong>:</strong></td>
<td width='100'><input name='admin_password' type='password' size='30' value='$info[1]'></td>
</tr>
<tr>
<td></td>
<td></td>
<td><div align ='right'><form name='pass' method='post' action='savepassword.php'>
<input type='submit' name='submit' value='Edit'>
</form></div></td>
</tr>
</table> ";
}while($info=mysql_fetch_row($result));
?>
and this is the process.
savepassword.php
<?php
session_start();
$conn = mysql_connect("localhost", "root", "")or die("Could not connect to server");
$db = mysql_select_db("Smartlocker", $conn)or die("Could not connect to database");
$sql = "UPDATE admin SET admin_id='$admin_id', admin_password='$admin_password'
WHERE admin_id='$admin' ";
$result = mysql_query($sql) or die ("Could not execute query");
if($result)
{
echo "
<table width='1291' height='401' border='1' bordercolor='C0F7FE' bgcolor='E9F1EA'>
<tr>
<td>Password successfully updated</td>
</tr>
</table> ";
}
?>
Did I miss out some codes or there is something wrong with it?