Hi All,
I am using the following code for form validation but i am getting an error saying that unexpected T_variable in line
<?php include("menu.inc");
include("tiki-setup.php");
?>
<div id="centerContent">
<p class="first-letter">Please fill the following form in for any enquiries that you may have:</p>
<p>
<?php
// if the form has been posted, analyse it:
if ($_POST) {
foreach ($_POST as $field => $value) {
$value = trim($value);
}
// creating variables
$inquiry=$_POST['inquiry'];
$title=$_POST['title'];
$first_name=$_POST['first_name'];
$last_name=$_POST['last_name'];
$email=$_POST['email'];
$phone=$_POST['phone'];
$message=$_POST['message'];
$reply=$_POST['reply'];
$contact=$_POST['contact'];
// create empty error variable
$error = "";
// check for data in required fields
if (($inquiry == "") || ($title == "") || ($first_name == "") || ($last_name == "") || ($email == "") || ($phone == "") || ($message == "") || ($reply == "") || ($contact == "")) {
$error = "Please fill in all the required fields!";
}
// validate first_name
if ((ctype_alpha($first_name) == FALSE
$error = "Please enter a valid name (Alphabets only)<br/>";
}
// validate surname
if ((ctype_alpha($last_name) == FALSE {
$error = "Please enter a valid last name (Alphabets only)<br/>";
}
// validate e-mail
if ((strpos($email, "@") === FALSE ||
(strpos($email, ".") === FALSE ||
(strpos($email, " ") != FALSE || // DON'T KNOW WHY USING "!=" SIGN
(strpos($email, "@") === FALSE || // DON'T KNOW WHY USING 3 "=" SIGN
(strpos($email, "@") > strrpos($email, "."))) {
$error = "Please enter a valid e-mail address<br/>";
}
// validate phone
if (is_numeric($phone) == FALSE {
$error = "Please enter a valid contact number (must contain numbers only)<br/>";
}
//If everything is OK then Confirmation of each field's data as filled by the user
else {
echo "<p><b>Nature of Inquiry:</b> $inquiry<br/>";
echo "<p><b>Title:</b> $title<br/>";
echo "<p><b>First Name:</b> $first_name<br/>";
echo "<p><b>Last Name:</b> $last_name<br/>";
echo "<p><b>E-mail:</b> $email<br/>";
echo "<p><b>Contact No.:</b> $phone<br/>";
echo "<p><b>Message:</b> $message<br/>";
echo "<p><b>Reply:</b> $reply<br/>";
echo "<p><b>Contact Method:</b> $contact<br/>";
echo "Thanks for contacting us. We will get back to you shortly!";
}
}
$smarty->assign('mid', 'tiki-validate.tpl');
$smarty->display("tiki.tpl");
?>
</p>
<table class="table">
<tr class="tr">
<td class="td"><form method="post" action="<?php echo $_SERVER['PHP_SELF'] ?>">
Nature of Enquiry:</td>
<td class="td"><select name="inquiry" value="<?php echo $inquiry ?>">
<option></option>
<option>General Inquiry</option>
<option>Price Quotation</option>
<option>Comments</option>
<option>Other</option>
</select></td>
</tr>
<tr class="tr">
<td class="td">Title:</td>
<td class="td"><select name="title" value="<?php echo $title ?>">
<option></option>
<option>Mr</option>
<option>Miss</option>
<option>Mrs</option>
<option>Other</option>
</select></td>
</tr>
<tr class="tr">
<td class="td">First Name:</td>
<td class="td"><input type="text" size="30" maxlength="30" name="first_name" value="<?php echo $first_name ?>"/></td>
</tr>
<tr class="tr">
<td class="td">Last Name:</td>
<td class="td"><input type="text" size="30" maxlength="30" name="last_name" value="<?php echo $last_name ?>"/></td>
</tr>
<tr class="tr">
<td class="td">E-mail:</td>
<td class="td"><input type="text" size="30" maxlength="30" name="email" value="<?php echo $email ?>"/></td>
</tr>
<tr class="tr">
<td class="td">Contact No.:</td>
<td class="td"><input type="text" size="30" maxlength="20" name="phone" value="<?php echo $phone ?>"/></td>
</tr>
<tr class="tr">
<td class="td">Message:</td>
<td class="td"><textarea rows="10" cols="50" wrap="physical" name="message" value="<?php echo $message ?>">
</textarea></td>
</tr>
<tr class="tr">
<td class="td">Reply Required:</td>
<td class="td"><input type="radio" name="reply" value="<?php echo $reply ?>"/>Yes
<input name="reply" type="radio"/>No
<input name="reply" type="radio"/>Maybe</td>
</tr>
<tr class="tr">
<td class="td">How would you like to be contacted (if required)?<br/><br/></td>
<td class="td"><input type="radio" name="contact" value="<?php echo $contact ?>"/>E-mail
<input type="radio" name="contact"/>Telephone</td>
</tr>
<tr class="tr">
<td class="td"></td>
<td class="td"><input type="reset" name="reset" value="Reset"/>
<input type="preview" name="preview" value="Preview"/></td>
<input type="submit" name="submit" value="Submit"/></td>
</form>
</tr>
</table>
</div>
Please help me on this......
Waiting for the reply...