I have a form that sends info to a table called osd_report. I have a page that pulls the info submitted and another user (employee) can update the submitters post. I have error checks throughout and and when the information is updated and saved, it says that it was saved, however, nothing is changed in the MySQL table. Can someone help me figure out what I did wrong?
Here is the code for the page that pulls the info and allows for updating:
[php]
<?php if ($_SERVER['HTTPS'] != "on") { $url = "https://". $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']; header("Location: $url"); exit; } include 'dbc.php'; //where all db info is stored page_protect(); //used by a login script to protect page $db_selected = mysql_select_db(DB_NAME, $link); if (!db_selected) { die('Can\'t use ' . DB_NAME . ': ' . mysql_error()); } $id = $_GET['id']; //this line pulls from another page where the link for this specific submission directs //here and where all submissions are stored if($_POST['doSave'] == 'Save') { // Filter POST data for harmful code (sanitize) foreach($_POST as $key => $value) { $data[$key] = filter($value); } mysql_query("UPDATE osd_report SET `first_name` = '$data[first_name]', `last_name` = '$data[last_name]', `company_name` = '$data[company_name]', //many more fields that have// //been removed for this psot// WHERE id='$id' ") or die(mysql_error()); //header("Location: contact_osd_results.php?msg=Profile Sucessfully saved"); $msg[] = "Report Information Saved"; } $rs_osd = mysql_query("select * from osd_report where id='$id'"); ?>[/php]
Here is a snippet from the form:
[php]
<?php while ($row_osd = mysql_fetch_array($rs_osd)) {?>How to reach the company:
First Name*:
//much more cut out//
<p>Date Updated:</p>
<p><input class="forms" type="text" name="date_updated" value="<? echo $row_osd['date_updated']; ?>" maxlength="" size="36"><br /><br /></p>
</div>
<div class="forms_all form_full">
<p align="center">
<input name="doSave" type="submit" id="doSave" value="Save">
</p>
</div>
<?php } ?>
[/php]
I need the form to update the information in a specific row by the “id” field.
I hope I have given enough information and code. If not, please advise and I will do my best to supply what is needed.
Thanks,
Clint