You are here: Contact Us script « PHP Programming Language « IT news, forums, messages
Contact Us script

Posted by thanos on 06/03/07 22:52

Hello,

I'm relatively new to PHP so I found this free contact us script on
the net that i was going to use for my Contact Us php page. Its works
pretty good except for error handling. I was wondering if any can
hlep me understand what is missing. I've posted the php files below
below. Contact.php calls the sendemail.php script. This appears to be
the validation code in the sendemail.php file. But i would like it to
validate and prefer a pop up box instead on the Contact.php page
before contining to the confirmation page (sendemail.php). Any help
would be appreciated.

Al

<?php
if(!$visitormail == "" && (!strstr($visitormail,"@") || !
strstr($visitormail,".")))
{
echo "<h2>Use Back - Enter valid e-mail</h2>\n";
$badinput = "<h2>Feedback was NOT submitted</h2>\n";
echo $badinput;
}
if(empty($visitor) || empty($visitormail) || empty($notes )) {
echo "<h2>Use Back - fill in all fields</h2>\n";
}



==========================CONTACT,PHP=============================
<table width="100%" cellpadding="5" border="2">
<tr><td><form method="post" action="sendemail.php">
<?php
$ipi = getenv("REMOTE_ADDR");
$httprefi = getenv ("HTTP_REFERER");
$httpagenti = getenv ("HTTP_USER_AGENT");
?>

<input type="hidden" name="ip" value="<?php echo $ipi ?>" />
<input type="hidden" name="httpref" value="<?php echo $httprefi ?>" />
<input type="hidden" name="httpagent" value="<?php echo $httpagenti ?
>" />

Your Name:<br />
<input type="text" name="visitor" size="35" />
<br />
Your Email Address:<br />
<input type="text" name="visitormail" size="35" />
<br />
<br />
Attention:<br />
<select name="attn" size="1">
<option value=" General Support ">General Inquiries </option>
<option value=" Sales n Billing ">Sales & Billing </option>
<option value=" Technical Support ">Technical Support </option>
<option value=" Webmaster ">Webmaster </option>
</select>
<br /><br />
Message:
<br />
<textarea name="notes" rows="25" cols="49"></textarea>
<br />
<input type="submit" value="Send Mail"/>
<br />
</form></tr></td>
</table>
==============================END OF SCRIPT======================

=====================SENDEMAIL.PHP script=========================
<?php
$ip = $_POST['ip'];
$httpref = $_POST['httpref'];
$httpagent = $_POST['httpagent'];
$visitor = $_POST['visitor'];
$visitormail = $_POST['visitormail'];
$notes = $_POST['notes'];
$attn = $_POST['attn'];
?>

<?php
if(!$visitormail == "" && (!strstr($visitormail,"@") || !
strstr($visitormail,".")))
{
echo "<h2>Use Back - Enter valid e-mail</h2>\n";
$badinput = "<h2>Feedback was NOT submitted</h2>\n";
echo $badinput;
}
if(empty($visitor) || empty($visitormail) || empty($notes )) {
echo "<h2>Use Back - fill in all fields</h2>\n";
}

$todayis = date("l, F j, Y, g:i a") ;
$attn = $attn ;
$subject = $attn;
$notes = stripcslashes($notes);
$message = " $todayis [EST] \n
Attention: $attn \n
Message: $notes \n
From: $visitor ($visitormail)\n
Additional Info : IP = $ip \n
Browser Info: $httpagent \n
Referral : $httpref \n";

$from = "From: $visitormail\r\n";
mail("info@yoursite.com", $subject, $message, $from);
?>

<table width=100% cellpadding="10" border="2">
<tr>
<th align="center"><h3> Confirmation of Message Sent</h3></th>
</tr>
<tr>
<td>
<b>IP:</b> <?php echo $ip ?>
<br />
<b>Attention:</b> <?php echo $attn ?>
<br />
<b>From:</b> <?php echo $visitormail ?>
<br />
<b>Date:</b> <?php echo $todayis ?>
<br />
<br />
Thank you <?php echo $visitor ?>, your message has been sent
successfully. We generally respond to emails within 24-48 hours.
Thanks for contacting us!
<br />
<br />
</td>
</tr>
<tr>
<td align="center">
<a href="/index.php"> Home </a>
</td>
</tr>
</table>
=========================END OF SCRIPT==============================

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация