Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

code doesn't update

Status
Not open for further replies.

richfield

IS-IT--Management
Jan 6, 2005
23
GB
Hi,

Im trying to update a Mysql table, but the following code does not seem to do it its not throwing up anu error messages either:

<code>
$LandlordID=$_REQUEST['id'];
if ($_POST['submit'] == "Update")
{


$query_update = "UPDATE landlord SET password = '" . $_POST['password'] . "', mobile
= '" . $_POST['mobile'] . "' WHERE userID ='$LandlordID'";
$result_update = mysql_query($query_update) or die(mysql_error());

$query = "SELECT * FROM landlord WHERE userID='$LandlordID'";
$result = mysql_query($query) or die(mysql_error());
$row = mysql_fetch_array($result);

?>

</code>

Is there any obvious error??
 
Is this the entire code? I don't see where you are connecting to the database.
 
nor where he's even closing the if statement.

*cLFlaVA
----------------------------
[tt]tastes great, less filling.[/tt]
 
this is a rotten egg:
Code:
$LandlordID=$_REQUEST['id'];

not very good for security.

Also, did you give your submit button the value "Update"?

<input type="submit" name="submit" value="Update" />

Also, put at the end of your query:
Code:
LIMIT 0, 1

I would also not use the $_REQUEST.
When the user logs in, you can set the user_id in session or in a $_POST['uid'] variable. You do not want to set userid = $_REQUEST.., as then an abuser can go and change the variable in the querystring!!


Also remember to secure your strings against abuse, before they touch your database!


I might have forgotten some now, but with theese mods, your script is much safer.

Olav Alexander Mjelde
Admin & Webmaster
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top