i am trying to validate a form so that all required fields are filled before submission. If they are not filled then an error message should appear..
But I keep getting this error:
"Parse error: parse error, unexpected '{' in C:\Program Files\wamp\www\template1\updateReceipt.php on line 31
"
Here is the code
<?php
include("connect.php");
if (!isset($_POST['Submit']))
{
$GpoNumber =$_POST['GpoNumber'];
$invoice=$_POST['invoice'];
$amount=$_POST['amount'];
$receiver=$_POST['receiver'];
$dateIn=$_POST['dateIn'];
$submitter=$_POST['submitter'];
// create empty error variable
$error = "";
// check for data in required fields
if (($GpoNumber == "") || ($invoice == "") || ($amount == "") || ($receiver == "") || ($dateIn == "") || ($submitter == "")) {
$error = "Please fill in all the required fields!";
}
// validate GpoNumber
[COLOR="Red"]if ((ctype_alpha($GpoNumber) == FALSE {[/COLOR]
$error = "Please enter a valid GpoNumber <br/>";
}
// validate invoice
if ((ctype_alpha($invoice) == FALSE {
$error = "Please enter a valid invoice <br/>";
}
// validate amount
if ((is_numeric($amount) == FALSE {
$error = "Please enter a valid amount <br/>";
}
// validate receiver
if ((ctype_alpha($receiver) == FALSE {
$error = "Please enter a valid receiver <br/>";
}
// validate date
if ((is_numeric($dateIn) == FALSE {
$error = "Please enter a valid date <br/>";
}
// validate submitter
if ((ctype_alpha($submitter) == FALSE {
$error = "Please enter a valid submitter <br/>";
}
?>
<body>
<div id="container">
<div id="intro">
<div id="pageHeader">
<h1><span>Department of Water Affairs<h3><font color='black'>Payment Process Tracking System</font></h3></span></h1>
</div>
<div id="linkList">
<div id="linkList2">
<div id="lmenu">
<ul>
<li><a href="index.html">Main Menu</a> </li>
<li><a href="receipt.php">Receipt Division</a> </li>
<li><a href="viewReceipt.php">View Details</a> </li>
<li><a href="deleteReceipt.php">Delete Details</a> </li>
</ul>
</div>
</div>
</div>
<div id="about">
<h3><span>Update Receipt Division Details</span></h3>
<form action="<?php echo($PHP_SELF) ?>" method="post">
<table width="400" border="0" cellpadding="0">
<tr><td>Company Name:</td>
<td><input type="text" NAME="CompanyName" size="30"></td></tr>
<tr><td><label>GPO Number</label></td>
<td>
<?php
$result=mysql_query("SELECT GpoNumber FROM receipt WHERE GpoNumber='$GpoNumber'")
?>
<select name ="GpoNumber">
<?php
while($receipt=mysql_fetch_array($result))
{
?>
<option value="<?php echo $receipt['GpoNumber'];?>"><?php echo $receipt['line[0]'];?></option>
<?php
}
?>
</select></td></tr>
<tr><td>Invoice Number:</td>
<td><input type="text" NAME="invoice" size="30"></td></tr>
<tr><td>Amount:</td>
<td><input type="text" NAME="amount" size="30"></td></tr>
<tr><td>Received By:</td>
<td><input type="text" NAME="receiver" size="30"></td></tr>
<tr><td>Date In:</td>
<td><input type="text" NAME="dateIn" size="30"></td></tr>
<tr><td>Submitted By:</td>
<td><input type="text" NAME="submitter" size="30"></td></tr>
<td colspan="2"> </td></tr>
<tr><td colspan="2" align="center"><input type="submit" name="Submit" value="UPDATE "/>
<input type="reset" name="ubmit" value="CLEAR"/></td></tr>
</table>
</form>
</div>
</div>
</div>
</body>
<?php
else
{
updateReceiptDetails($CompanyName,$GpoNumber,$invoice,$amount,$receiver,$dateIn,$submitter);
}
}
?>