Hey guyz? I am a newbie in php and have managed to create a website using php though spam bots have been sending me blank emails since the form is not validated. i have tried to validate it but i have not succeed. kindly assist. Below is the code of the contacts form. Thanks
<style type="text/css">
<!--
.insid {font-family: Tahoma;
font-size: 11px;
color: #003366;
font-weight: bold;
}
-->
TD.error
{
color: red;
font-weight: bold;
}
</style>
<?php
if (count($errors) > 0)
echo "<p>There were some errors in your submitted form, please correct them and try again.</p>";
?>
To contact us kindly please fill in the form below.<br />
Please take time to send us your views, comments, suggestions or complaints:
<form action="sendmail.php" method="POST" name="contact" id="contact">
<table width="98%" border="0" align="center" cellpadding="4" cellspacing="3" bgcolor="#FFFFFF">
<tr>
<td width="28%"><div align="right"></div></td>
<td width="72%" valign="top"><div align="left"><strong>Menengai Holidays Ltd</strong><br />
P.O. Box 2260 - 00202, KNH,<br />
Nairobi, Kenya<br />
First Floor, Duplex Apartments,<br />
Bunyala/Lower Hill Road, Upper Hill<br />
Tel No: +254 – 20- 2733702<br />
Fax No: +254 – 20 – 2725021<br />
Cell: +254 – 720– 950500<br />
<strong>Email:</strong>
<?php
function hideemail($email) {
$mail = "";
for ($i = 0; $i < strlen($email); $i++) {
$mail .= '&#' . ord($email{$i}) . ';';
}
return $mail;
}
echo hideemail("info@me.com"); ?> </div></td>
</tr>
<tr>
<td><div align="right"></div></td>
<td valign="top"><div align="left"><strong>US Office Contacts:</strong><br />
10418 Pickerel Lane, <br />
Charlotte, NC 28213 <br />
Tel: +1 704 904 1081 <br />
<b>Email:</b> <strong style="font-weight: 400">emwasi@menengaiholidays.com</strong> </div></td>
</tr>
<tr>
<td> </td>
<td><div align="left"><font size='2' color='#ff0000'>*</font> Denotes Required fields. </div></td>
</tr>
<tr>
<td colspan="2"><div align="left"><?php include_once( "20090106-76ee.lib.php" ); ?>
<style type='text/css'>
.form_title{
color : #000000;
font-size: 13px;
font-family: verdana, Geneva, Arial, Helvetica, sans-serif;
font-weight : bold;
}
.form_field {
font-size : 13px;
font-family : Verdana, Arial, Helvetica, sans-serif;
color : #474747;
font-weight : bold;
text-align:left;
}
.form_text{
font-size : 11px;
font-family : Verdana, Arial, Helvetica, sans-serif;
color : #000000;
}
.text_box{
font-size : 11px;
font-family : Verdana, Arial, Helvetica, sans-serif;
color : #000000;
width:200px;
}
.text_area{
font-size : 11px;
font-family : Verdana, Arial, Helvetica, sans-serif;
color : #000000;
width:200px;
height:60px;
}
.text_select{
font-size : 11px;
font-family : Verdana, Arial, Helvetica, sans-serif;
color : #000000;
}
.form_error{
font-size : 11px;
font-family : Verdana, Arial, Helvetica, sans-serif;
color : #ff0000;
font-weight : bold;
}
.copyright{
font-size : 11px;
font-family : Verdana, Arial, Helvetica, sans-serif;
color : #000000;
}
</style>
<?php
if( !$isHideForm ):
global $sErr ;
if( $sErr ) print "<br><a name='error'></a><center><font class='form_error' >$sErr</font></center><br>";
$starColor = $sErr ? "#ff0000" : "#000000";
$style=" class='form_text' ";
?>
<?php
if (count($errors) > 0)
echo "<p>There were some errors in your submitted form, please correct them and try again.</p>";
?>
<form name="frmFormMail" action="<?php print PHP_SELF ?>" method='post' enctype='multipart/form-data'>
<input type='hidden' name='formmail_submit' value='Y'>
<input type='hidden' name='esh_formmail_recipient' value="info@menengaiholidays.com">
<input type='hidden' name='esh_formmail_subject' value="New Inquiry">
<input type='hidden' name='esh_formmail_cc' value="">
<input type='hidden' name='esh_formmail_bcc' value="">
<input type='hidden' name='esh_formmail_return_subject' value="Thank you for contacting us.">
<input type='hidden' name='esh_formmail_return_msg' value="Hi,
We have received your email and we will get back to you shortly. Thanks in advance.
Regards,
Menengai Holidays">
<input type='hidden' name='esh_formmail_mail_and_file' value="">
<input type='hidden' name='esh_formmail_charset' value="">
<table cellspacing='16' cellpadding='0' border='0' >
<tr>
<td class="form_field" valign='top' align='right'>Full Names: </td><td width='10' aligh='right' valign='top'> <font size='2' color='#ff0000'>*</font> </td>
<td class="form_text">
<input type="text" name="Full_Names" value="<?php print HtmlSpecialChars( $HTTP_POST_VARS[ "Full_Names" ] ); ?>" class='text_box'>
<td class="error"><?= $errors['Full_Names'] ?></td>
</td>
</tr>
<tr>
<td class="form_field" valign='top' align='right'>E-mail </td><td width='10' aligh='right' valign='top'> <font size='2' color='#ff0000'>*</font> </td>
<td class="form_text">
<input type="sender's email" name="E-mail" value="<?php print HtmlSpecialChars( $HTTP_POST_VARS[ "E-mail" ] ); ?>" class='text_box'>
<td class="error"><?= $errors['E-mail'] ?></td>
</td>
</tr>
<tr>
<td class="form_field" valign='top' align='right'>Country: </td><td width='10' aligh='right' valign='top'></td>
<td class="form_text">
<input type="text" name="Country" value="<?php print HtmlSpecialChars( $HTTP_POST_VARS[ "Country" ] ); ?>" class='text_box'>
</td>
</tr>
<tr>
<td class="form_field" valign='top' align='right'>Subject: </td><td width='10' aligh='right' valign='top'></td>
<td class="form_text">
<input type="text" name="Subject" value="<?php print HtmlSpecialChars( $HTTP_POST_VARS[ "Subject" ] ); ?>" class='text_box'>
</td>
</tr>
<tr>
<td class="form_field" valign='top' align='right'>Message: </td><td width='10' aligh='right' valign='top'></td>
<td class="form_text">
<textarea name="Message" rows=4 cols=25 ><?php print HtmlSpecialChars( $HTTP_POST_VARS[ "Message" ] ); ?></textarea>
<td class="error"><?= $errors['Message'] ?></td>
</td>
</tr>
<tr><td colspan=3 align='center'><input type='submit' value='Submit'> <input type='button' value='Cancel' onClick="location.href='/';"></td></tr>
</table>
</form>
<!-- ======================= End: ======================= -->
<?php
if( $sErr ) print "<script language='javascript' type='text/javascript'>location.href='#error';</script>";;;
else: //!$isHideForm
print( "<br><br><hr><center><b>Your form has been sent. Thank you.</b><br><br><input type='button' value='Home' onclick=\"location.href='/';\"></center><br><br>" );
endif; //!$isHideForm
?>
<!-- -------------------------------------- COPY RIGHT -------------------------------------- -->
</div></td>
</tr>
<tr>
<td> </td>
<td><div align="left"><strong> <a href="index.php?mod=15"> Click here</a></strong> to view our General Terms and Conditions</div></td>
</tr>
</table>
</form>