Greetings,
I am using one database and I want to have 3 forms acessing it. My original form, submits to the db and is assigned a timestamp. (this works fine)The second form will update the database as will a 3rd form.
My update form(s) is causing me grief by either overwriting the original timestamp, or using a default of 0000-00-00 00:00:00. (not acceptable, I have tried both timestamp and datetime)
I am sorry, I am having problems and am not sure if this is a problem with my form, or the database. I will post the code for the first update form below, Thank you in advance,
<?php
if (!(isset($_POST['SubmitForm_x']))) {
$whereStmt = ' IDNum="'.addslashes($_GET['IDNum']).'"';
$selectSql = 'SELECT * FROM cactus2 WHERE '.$whereStmt ;
$Result = $MyDb->f_ExecuteSql($selectSql);
$Resultset = $MyDb->f_GetRecord($Result);
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Update</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="style/style.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="scripts/pdw.
js"></script>
<script type="text/javascript">
function checkForm(){
formErrors = new Array();
isValidAny(document.getElementById('TLIN_ID'), 'TLIN:: null', true);
var errorText = '';
if (formErrors.length > 0){
for (var i=0; i<formErrors.length; i++)
errorText = errorText + formErrors[i] + '\n';
alert(errorText);
return false;
}
return true;
}
</script>
</head>
<body>
<form name="UpdateForm" method="post" action="<?php echo $_SERVER['PHP_SELF'] ?>" onSubmit="return checkForm()">
<div id="insertblock">
<table>
<tr>
<td class="tableheader" colspan="2">Update</td>
</tr>
<tr>
<th>Assigned to:</th>
<td><input type="text" name="TLIN" id="TLIN_ID" value="<?php echo $Resultset['TLIN']; ?>"></td>
</tr>
<tr>
<?php
echo '<td class="tablefooter" colspan="2"><a href="javascript
:history.back()"><img src="style/back.gif" alt="Back"></a>';
echo '<input type="image" src="style/update.gif" name="SubmitForm">';
?>
<input type="hidden" name="hidden_whereStmt" value='<?php echo $whereStmt; ?>'></td>
</tr>
</table>
</div>
</form>
</body>
</html>
<?php
}
else {
$updateSql = 'UPDATE cactus2 SET '
." TLIN='".addslashes($_POST['TLIN'])."'"
.' WHERE '.stripslashes($_POST['hidden_whereStmt']);
// cast it to an integer to make it safe
$id = (int) $_POST['id'];
$sql = "
...
WHERE id=$id
";
$MyDb->f_ExecuteSql($updateSql);
header('Location: list.php');
}
?>