update not working in mysql

wxdqz

New Member
hi,
here is the code i am having the problem with..

<?php

require ("auth.php");

if ($submit) {

$sql = "UPDATE acl SET first='$first',last='$last',address='$address',city='$city',state='$state',postcode='$postcode' WHERE username='$username'";

$result = mysql_query($sql);

echo "Information updated successfully!\n";

} else {

$sql = "SELECT * FROM acl WHERE username='$username'";

$result = mysql_query($sql);

$myrow = mysql_fetch_array($result);

$first = $myrow["first"];

$last = $myrow["last"];

$font_type = Arial;

?>

<form method=get action="<?php echo $PHP_SELF?>">
<table width="75%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="23" width="50%"><font face="Arial, Helvetica, sans-serif"><b>Control
Panel Username:</b></font></td>
<td height="23" width="50%"><font face="Arial, Helvetica, sans-serif"><? echo $myrow["username"]?></font></td>
</tr>
<tr>
<td height="23" width="50%"><font face="Arial, Helvetica, sans-serif"><b>Control
Panel Password:</b></font></td>
<td height="23" width="50%"><input type="password" name="password" value=http://www.phpbuilder.com/board/archive/index.php/"<? echo $myrow["password"]?>"></td>
</tr>
<tr>
<td height="23" width="50%"><font face="Arial, Helvetica, sans-serif"><b>First
Name:</b></font></td>
<td height="23" width="50%"><input type="text" name="first" value="<? echo $first ?>"></td>
</tr>
<tr>
<td height="23" width="50%"><font face="Arial, Helvetica, sans-serif"><b>Last
Name:</b></font></td>
<td height="23" width="50%"><input type="text" name="last" value="<? echo $last ?>"></td>
</tr>
<tr>
<td height="23" width="50%"><font face="Arial, Helvetica, sans-serif"><b>Address:</b></font></td>
<td height="23" width="50%"><input type="text" name="address" value="<? echo $myrow["address"]?>"></td>
</tr>
<tr>
<td height="23" width="50%"><font face="Arial, Helvetica, sans-serif"><b>City:</b></font></td>
<td height="23" width="50%"><input type="text" name="city" value="<? echo $myrow["city"]?>"></td>
</tr>
<tr>
<td height="23" width="50%"><font face="Arial, Helvetica, sans-serif"><b>State:</b></font></td>
<td height="23" width="50%"><input type="text" name="state" value="<? echo $myrow["state"]?>"></td>
</tr>
<tr>
<td height="23" width="50%"><font face="Arial, Helvetica, sans-serif"><b>Postal
/ Zip Code:</b></font></td>
<td height="23" width="50%"><input type="text" name="postcode" value="<? echo $myrow["zipcode"]?>"><input type="hidden" name=username value="<? echo $myrow["username"]?>"></td>
</tr>
<tr>
<td height="23" width="50%"><font face="Arial, Helvetica, sans-serif"><b></b></font></td>
<td height="23" width="50%">&nbsp;</td>
</tr>
<tr>
<td height="23" width="50%">
<div align="right"><font face="Arial, Helvetica, sans-serif"><b>
<input type="submit" name="submit" value="Modify">
</b></font></div>
</td>
<td height="23" width="50%">
<input type="reset" name="Reset" value="Reset">
</td>
</tr>
</table></form>

<br>
&nbsp; <br>
<font face="Arial, Helvetica, sans-serif" size="2"><a href="<?echo "$PHP_SELF";?>">Click
here to return to the main page</a></font>

<?

}

?>

Basically, when someone goes to this page, first of all the auth.php file checks if the user has the right cookie or not and if they do shows the desired content. However, if they dont have the cookie, it shows them a login screen.

however that is in the auth.php and not this file. I want this file to allow users to edit their information. However, the problem i am having is this:

when i log in and go to this page, it shows my details fine but if i try to modify it, and i click submit, it says "Information updated successfully!" but when i go back and refresh the page, the information remains the same.

Any ideas anyone? i would appreciate any sort of help whatsoever

Thanks,
Khilan Gudka

PS, also, the username variable is coming from the auth.php file.
 
Back
Top