Forum Moderators: coopster
I have a corporate order form that I've constructed in php and it works great. My issue is I have created an " update " option on a new version of the form to update the database information based on the specific company_id and job_num_id.
How do I go about adding an update/editing option to a form?
Would look something like this: after the variables were listed:
<?php
$customer =$_POST['customer_id']
$jobnum=$_POST['']
...
mysql_query("UPDATE TABLE SET('$customer', '$jobnum', '$partdes')");
Print "Your information has been successfully added to the database.";
php?>
I just want to be sure that is right.
$customer =$_POST['customer_id']
$jobnum=$_POST['']
...
$result = mysql_query("UPDATE `table_name` SET `customer` = '$customer', `jobnum` = '$jobnum', `partdes` = $partdes' WHERE `company_id` = '$company_id' AND `job_num_id` = '$job_num_id'");
if($result)
echo "Your information has been successfully added to the database.";
else
echo "Failed";
Just make sure that you escape the variables that are going into the query using mysql_real_escape_string [php.net]. I excluded this in my example code above to keep it simpler, but it is a necessary part that cannot be left out.
$customer = mysql_real_escape_string($_POST['customer_id']);
Make sure to do it for each, however.