//page2 edit button code.. page2 send the data back to page1 if user wants to edit
<a href="purchase_form1.php?id=<?php echo $id; ?>" class="button4">Edit</a>
//page1 php code. here the form is on this page
//This GET[id] is sent from page2 which is user view page of the form on page1.
//If user do not like the form he clicks on edit button (code above) and reaches this page
$id = 0;
if(isset($_GET['id']) && !empty($_GET['id']))
$id = (int)$_GET['id'];
}
$query = "SELECT * from db_purchase_form where id = $id";
$result = mysql_query($query);
$has_data = false;
while($row = mysql_fetch_row($result))
{
$has_data = true;
$product_name = $row[1];
$choice_actor = $row[2];
$user_name = $row[3];
$user_email = $row[4];
$vdo_script = $row[5];
$hrt_msg = $row[6];
$portApproval = $row[7];
$delivery = $row[8];
$net_price = $row[9];
}
if(isset($_POST['submit']))
{
// here i am trying to UPDATE DB if the user edited the form AND CLICKS ON submit
if ($has_data == true){
$sql = "UPDATE db_purchase_form ". "SET db_product_name = \".pSQL($product_name).'\' , db_actor = \".pSQL($choice_actor).'\', db_user_name = \".pSQL($user_name).'\', db_user_email = \".pSQL($user_email).'/', db_vdo_script = \".pSQL($vdo_script).'\', db_hrt_msg = \".pSQL($hrt_msg).'\', db_port_approval = \".pSQL($portApproval).'\', db_delivery = \".pSQL($delivery).'\', db_price = \".pSQL($net_price).'\', db_date_time = NOW()". "WHERE id = '{$id}'";
}
// form validation and insert into DB if form is okay
what shall be happening is if the GET[id] is set then UPDATE query shall run i.e. user has edited the form and saving changes to that id, otherwise the new id shall be inserted.
What is happening is, when user clicks on edit on page2, and reaches page1 & make changes to page1 form and clicks submit, instead of updating the same ID the page is inserting a new id to the db.
Help friends!!!
but it is not working the way it shall be working, any help friends?
Thanks a lot