Hi all,
I have a problem with my update code.after user log in,they can choose to update their details.This code can track user but it cannot do update.When they go to this page,all their particulars already there and they can just type again and click submit to update.
The problem is user's particulars are not displayed,therefore they cant do the update.
this is my code
<?php
mysql_connect("localhost", "ODBC", "") or die(mysql_error());
mysql_select_db("wms") or die(mysql_error());
//checks cookies to make sure they are logged in
if(isset($_COOKIE['ID_my_site']))
{
$username = $_COOKIE['ID_my_site'];
$pass = $_COOKIE['Key_my_site'];
$check = mysql_query("SELECT * FROM users WHERE username = '$username'")or die(mysql_error());
while($info = mysql_fetch_array( $check ))
{
//if the cookie has the wrong password, they are taken to the login page
if ($pass != $info['password'])
{ header("Location:http://localhost/projek/home.php");
}
//otherwise they are shown the user area
else
{
$name = $_GET[nama];
$jawatan = $_GET[jawatan];
$no_kp = $_GET[no_kp];
$password = $_GET[password];
if(isset($_GET['update']))
{
$sql = "UPDATE users SET username = '$name', jawatan = '$jawatan', no_kp = '$no_kp', password = '$password' WHERE username = '$username'";
$result = mysql_query($sql);
echo "Thank You!Information Updated.\n";
$result=mysql_query("SELECT * FROM users WHERE username='$username'",$db);
$myrow=mysql_fetch_array($result);
}
else if($name = $_GET[nama])
{
$result=mysql_query("SELECT * FROM users WHERE username ='$username'",$db);
$myrow=mysql_fetch_array($result);
}
?>
<form method="get" action="<?php echo $PHP_SELF?>">
<input type="hidden" name="id" value="<?php echo $myrow["id"]?>">
Nama:<input type="text" name="nama" value=<?php echo $myrow["username"]?>><br>
Jawatan:<input type="text" name="jawatan" value=<?php echo $myrow["jawatan"]?>><br>
No Kad Pengenalan:<input type="text" name="no_kp" value=<?php echo $myrow["no_kp"]?>><br>
Katalaluan:<input type="text" name="katalaluan" value=<?php echo $myrow["password"]?>><br>
<input type="Submit" name="update" value="Kemaskini">
</form>
<?
}
}
}
?>
Can someone please help?