Page 1 of 1

update data in my php form

Posted: Wed Aug 18, 2010 1:28 pm
by heshan
Hi all,

I want to modify details in my form. Therefore i use following code. But it does not work properly.Can anyone check and see where am i go wrong?

Code: Select all

<?php

$customer_id = $_POST['customer_id'];
$nic =$_POST['nic'];
$full_name=$_POST['full_name'];
$name_with_initials=$_POST['name_with_initials'];
$address=$_POST['address'];
$contact_number=$_POST['contact_number'];
$gender=$_POST['gender'];

$result = mysql_query("UPDATE customer SET `nic` = '$nic', `full_name` = '$full_name', `name_with_initials` =                      $name_with_initials', address = '$address', contact_number = '$contact_number', gender  = '$gender'  WHERE `customer_id` = '$customer_id' ");
if($result)
echo "Your information has been successfully added to the database.";
else
echo "Failed";
?>
Thanks,
Heshan

Re: update data in my php form

Posted: Wed Aug 18, 2010 2:09 pm
by AbraCadaver
What does "not work properly" mean? Add a or die(mysql_error()) to the end of the mysql_query() call.

Also, someone is going to destroy your database or collect some sensitive info. Read here: http://www.php.net/manual/en/security.d ... ection.php

Re: update data in my php form

Posted: Wed Aug 18, 2010 2:14 pm
by heshan
Simply the code is not correct. It isn't to do with any security features.
I think there should be an error in this code which i cannot find. That is the one i am looking for :( :(

Re: update data in my php form

Posted: Wed Aug 18, 2010 2:31 pm
by AbraCadaver
AbraCadaver wrote:Add a or die(mysql_error()) to the end of the mysql_query() call.
Also, I don't see you connecting or selecting a database.

Re: update data in my php form

Posted: Wed Aug 18, 2010 9:02 pm
by mikosiko
other than the good guidance about security that AbraCadaver gave to you (and you should read it if you no are aware of the topic) in this line

Code: Select all

`name_with_initials` =                      $name_with_initials'
you are missing a quote

Re: update data in my php form

Posted: Thu Aug 19, 2010 2:03 am
by heshan
yeah , i got the point. thanks everyone :D