Hi Again,
I have attached my code for easier viewing. I'm getting an Undefined variable error on line 97.
Line 97 has
if ($an && $ts && $ds) { //if everything’s OK
but according to the manual I have everything is fine. Can someone with more experience than I (That's just about everyone) have a look at me code.
Thanks.............
<?php
ob_start();
session_start();
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>NCC Cheque Register - Update</title>
<?php
include ('..\includes\cssinclude.php');
include ('..\includes\meta.php');
?>
<script language="javascript" src="..\cal2.js">
/*
Xin's Popup calendar script- Xin Yang ([url]http://www.yxscripts.com/[/url])
Script featured on/available at [url]http://www.dynamicdrive.com/[/url]
This notice must stay intact for use
*/`
</script>
<script language="javascript" src="..\cal_conf2.js">
</script>
</head>
<body>
<div id="content">
<?php
$today = date("F j, Y"); // Date Format: Month Day, Year
include ('..\includes\outline.php');
?>
<br>
<form action="chq_register.php" method="post" name="chq_register2" onsubmit="return invalid_entry(chq_register2)">
<p align="left"><fieldset><legend>Update the Date Forwarded:</legend></p><br>
<table width="60%" border="0" align="center" cellspacing="4">
<tr>
<td width="42%"><div align="right">Account Number </div></td>
<td width="58%"><input type="text" name="Account_Number_2" onfocus="document.chq_register2.Account_Number_2.style.backgroundColor='#F4F4B7'" onblur="document.chq_register2.Account_Number_2.style.backgroundColor='white'"></td>
</tr>
<tr>
<td><div align="right">Cheque Total </div></td>
<td><input type="text" name="Total_2" onfocus="document.chq_register2.Total_2.style.backgroundColor='#F4F4B7'" onblur="document.chq_register2.Total_2.style.backgroundColor='white'"></td>
</tr>
<tr>
<td><div align="right">Date Forwarded </div></td>
<td><input type="text" name="Date_Sent_2" onclick="chq_register2.Date_Sent_2.value=''" onfocus="document.chq_register2.Date_Sent_2.style.backgroundColor='#F4F4B7'" onblur="document.chq_register2.Date_Sent_2.style.backgroundColor='white'">
<a href="javascript:showCal('Calendar4')"><img src="date.png"></a></td>
</tr>
</table>
<br>
<div align="center">
<input type="submit" name="Submit1" value="Add to Account">
</div>
<?php
//if the user pressed the submit button (if it is set)
if (isset($_POST['Submit1'])) {
require_once('Cheq_Register\mysql_connect_register.php');
function escape_data ($data) {
global $dbc;
if (int_get('magic_quotes_gpc')) {
$data = stripslashes($data);
}
return mysql_real_escape_string($data, $dbc);
} //End of function
$message = NULL; // Create an empty variable
// Check for an Account Number
if(empty($_POST['Account_Number_2'])) {
$an = FALSE;
$message .='<p>You Forgot to enter the Account Number</p>';
} else {
$an = escape_data($_POST['Account_Number_2']);
}
// Check for a Cheque Total
if(empty($_POST['Total_2'])) {
$ts = FALSE;
$message .='<p>You Forgot to enter the Cheque Total</p>';
} else {
$ts = escape_data($_POST['Total_2']);
}
// Check for a Date Forwarded
if(empty($_POST['Date_Sent_2'])) {
$ds = FALSE;
$message .='<p>You Forgot to enter the Date Forwarded</p>';
} else {
$ds = escape_data($_POST['Date_Sent_2']);
}
}
if ($an && $ts && $ds) { //if everthing's OK
$query = "SELECT Account_Number FROM accounts WHERE (Account_Number_2='$an' AND Total_2='$ts')";
$result = @mysql_query ($query);
$num = mysql_num_rows ($results);
if ($num == 1) {
$row = mysql_fetch_arry($result, MYSQL_NUM);
// Make the query to update the datebase
$query = "UPDATE accounts SET Date_Sent_2='$ds' WHERE Account_Number_2=$row[0]";
$result = @mysql_query ($query); //Run the query
if (mysql_affected_rows() == 1) { //if it ran OK
echo '<p><b>Done as per your request</p></b>';
exit(); //Quit the script
} else { //if it did not run OK
$message = '<p>An Error has occured</p><p>' . mysql_error() . '</p>';
}
mysql_close(); //close the connection
if (isset($message)) {
echo "<font color=\"red\">" . $message . "</font>";
}
}
}
?>
<p> </p>
</fieldset>
</form>
</div>
</body>
</html>