<?php
if ( $_POST['submit'] ) {
$valid = 8768;
$name = $_POST['name'];
if ( empty($name) ) {
$valid = 3534;
$name_error = 'You did not enter your name';
}
$company = $_POST['company'];
if ( empty($company) ) {
$valid = 3534;
$company_error = 'You did not enter your company';
}
$email = $_POST['email'];
//EMAIL VERIFICATION
function CheckMail($email) // this function checks if the email format is ok,
//if the chars are allowed, if there are enough chars in the TLD learn more
//about eregi function here: [URL unfurl="true"]http://www.php.net/manual/en/function.eregi.php[/URL]
{
if(eregi("^[0-9a-z]([-_.]?[0-9a-z])*@[0-9a-z]([-.]?[0-9a-z])*\.[a-z]{2,4}$",$email)){
return true;
}
else
{
return false;
}
}
if ((empty($email)) || (!CheckMail($email))) //here we check if the email is
//empty and if the previous function controls are passed, if there are
//errors the user is sent to a previously prepared custom error page
{
$valid=3534;
$email_error = 'Please enter a valid Email address';
}
$domains = array('@dodo','@hotmail', '@yahoo', '@gmail', '@aol','@TEE','@apat','@interfere','@inwind','@isiline','@izsmportici','@libero','@liero','@rai','@tin','@tinet','@tiscali');
$domain = strstr($email,'@');
$domain2 = explode('.', $domain);
if (in_array($domain2[0], $domains)) {
$valid = 3534;
$email_error = 'Sorry, Internet Email accounts are not allowed';
}
$tel = $_POST['telephone'];
$fax = $_POST['fax'];
$subject = $_POST['subject'];
if ( empty($subject) ) {
$valid = 3534;
$subject_error = 'You did not enter a subject';
}
$comments = $_POST['comments'];
if ( empty($comments) ) {
$valid = 3534;
$comments_error = 'You did not enter any comments';
}
$dept = $_POST['D1'];
$deptadd = "{$dept}@myserver.com.au";
$message .= 'Name: ' . $name . "\n";
$message .= 'Company: ' . $company . "\n";
$message .= 'Email: ' . $email . "\n";
$message .= 'Tel: ' . $tel . "\n";
$message .= 'Fax: ' . $fax . "\n\n";
$message .= 'Comments: ' . "\n";
$message .= $comments . "\n";
if ( $valid == 8768 ) {
$sendto = $deptadd;
$headers = 'From: Contact Form <' . $email . '>' . "\r\n" . 'Reply-To: ' . $email . "\r\n";
mail($sendto, $subject, $message, $headers);
header ("Location: index.php?view=contact_thanks");
}
}
?>
<html>
<form action="index.php?view=contact2" method="post">
<font size="2">
<label for="name">
<p></p><img border="0" src="image_folder1/contactus2.jpg" width="117" height="26"></label></font><p> </p>
<table border="0" width="100%" id="table1">
<tr>
<td width="117"><div align="left"><font size="2" color="#000080" face="Verdana, Arial, Helvetica, sans-serif">
<label for="name">Name: </label>
</font></div></td>
<td width="176"><font size="2" color="#000080" face="Verdana">
<input type="text" name="name" value="<?php echo $name;?>" size="20" /></font></td>
<td><font color="#000080" size="2">
<?php echo $name_error;?>
</font></td>
</tr>
<tr>
<td width="117"><div align="left"><font size="2" color="#000080" face="Verdana, Arial, Helvetica, sans-serif">
<label for="email">Email: </label>
</font></div></td>
<td width="176"><font size="2" color="#000080" face="Verdana">
<input type="text" name="email" value="<?php echo $email;?>" size="20" /></font></td>
<td><font color="#000080" size="2">
<?php echo $email_error;?>
</font></td>
</tr>
<tr>
<td width="117"><div align="left"><font size="2" color="#000080" face="Verdana, Arial, Helvetica, sans-serif">
<label for="company">Company: </label>
</font></div></td>
<td width="176"><font size="2" color="#000080" face="Verdana">
<input type="text" name="company" value="<?php echo $company;?>" size="20" /></font></td>
<td><font color="#000080" size="2">
<?php echo $company_error;?>
</font></td>
<br />
</tr>
<tr>
<td width="117"><div align="left"><font size="2" color="#000080" face="Verdana, Arial, Helvetica, sans-serif">
<label for="telephone">Telephone: </label>
</font></div></td>
<td width="176"><font size="2" color="#000080" face="Verdana">
<input type="text" name="telephone" value="<?php echo $tel;?>" size="20" /></font></td>
<td><font color="#000080" size="2"> </font></td>
</tr>
<tr>
<td width="117"> <div align="left"><font color="#000080" size="2" face="Verdana, Arial, Helvetica, sans-serif">Fax:
</font></div></td>
<td width="176"><font size="2" color="#000080" face="Verdana">
<input type="text" name="fax" value="<?php echo $fax;?>" size="20" /></font></td>
<td><font color="#000080" size="2"> </font></td>
</tr>
<tr>
<td width="117"><div align="left"><font size="2" color="#000080" face="Verdana, Arial, Helvetica, sans-serif">
<label for="name">Subject: </label>
</font></div></td>
<td width="176"><font size="2" color="#000080" face="Verdana">
<input type="text" name="subject" value="<?php echo $subject;?>" size="20" /></font></td>
<td><font color="#000080" size="2">
<?php echo $subject_error;?>
</font></td>
</tr>
</table>
<p>
<select size="1" name="D1" style="color: #000080; font-family: Verdana; font-size: 10pt">
<option value="val">Sales</option>
<option value="liz"> Support </option>
<option value="david">Accounts </option>
<option value="liz">Further Information </option>
</select></p>
<p><font size="2">
<?php echo $comments_error;?>
<br />
<br />
<textarea name="comments" rows="10" cols="33"></textarea><br />
<br />
</font>
<input type="submit" name="submit" value="Send" style="font-family: Verdana; font-size: 10pt;"/>
</p>
</form>
</html>