Hi All
I have a simple form that allows users to update the invoice received date to the current date which works fine , The user enter a waybillnumber and it will update.
I want to check if waybills exists before it send an update to the database, If they try to update a waybill that does not exist it should send an error message ,i need help with that
my form below
<?php
require ('paths.php');
define('VDAEMON', false);
require(REPOSITORY.'vdaemon/vdaemon.php');
//strip out anything malicious
submissionClean($_POST);
foreach($HTTP_POST_VARS as $varname => $value)
$formVars[$varname]=$value;
require_once("db_connect.php");
$query="SELECT * FROM Internal_Docs_waybills_outstanding WHERE WaybillNumber = \"".$formVars["WaybillNumber"]."\"";
$result=mysql_query($query) or die("Cannot Select from Internal Docs waybills outstanding ");
$row=mysql_fetch_array($result);
$formVars = array();
$formVars["Waybill_Date"]=$row["Waybill_Date"];
$formVars["Date_Invoice_Received"]=$row["Date_Invoice_Received"];
$formVars["Admin_Checked"]=$row["Admin_Checked"];
$formVars["WaybillNumber"]=$row["WaybillNumber"];
?>
<html>
<head>
<title><?php $pageTitle = 'Nikita DocProc System'; echo $pageTitle; ?></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta name="keywords" content="<?php echo $keywords;?>" />
<meta name="description" content="<?php echo $description;?>" />
<link href="styles/main.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div align="center">
<div align="center" class="inner">
<h2>Nikita DocProc</h2>
<p>Please press the "Submit" button to update the Date Invoice Recieved</p>
<form method="post" action="postupdate.php">
<table>
<tr>
<td><font class="normaltext">Waybill_Date</font></td>
<td><input type="text" name="Waybill_Date"
value="<? echo $formVars["Waybill_Date"]; ?>" size=15></td>
</tr>
<tr>
<td><font class="normaltext">Waybill Number </font></td>
<td><input type="text" name="WaybillNumber"
value="<? echo $formVars["WaybillNumber"]; ?>" size=15></td>
</tr>
<tr>
<td><input type="submit" value="Submit"></td>
</tr>
</div>
</div>
</body>
</html>
file to update
<html>
<head>
<title><?php $pageTitle = 'Nikita DocProc System'; echo $pageTitle; ?></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta name="keywords" content="<?php echo $keywords;?>" />
<meta name="description" content="<?php echo $description;?>" />
<link href="styles/main.css" rel="stylesheet" type="text/css" />
</head>
<div>
<div align="center">
<div align="center" class="inner">
<h2>Nikita DocProc</h2>
<?php
foreach($HTTP_POST_VARS as $varname => $value)
$formVars[$varname]=$value;
require_once("db_connect.php");
echo "<p>Date Invoiced Received updated<br><a href=\"index.php\">click here</a> to update another record<br></p>";
$query="UPDATE Internal_Docs_waybills_outstanding set
Date_Invoice_Received= NOW() WHERE WaybillNumber = \"".$formVars["WaybillNumber"]."\"";
mysql_query($query) or die("Cannot Update Date Invoice Received on Internal Docs waybills outstanding ");;
?>
<p>Administrators <a href="http://www.tshisevhe.co.za/" target="_blank">CLICK HERE</a> to edit/add Documement Control Information.</p>
</div>
</div>
</body>
</html>