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(!$visitormai l == "" && (!strstr($visit ormail,"@") || !
strstr($visitor mail,".")))
{
echo "<h2>Use Back - Enter valid e-mail</h2>\n";
$badinput = "<h2>Feedba ck was NOT submitted</h2>\n";
echo $badinput;
}
if(empty($visit or) || empty($visitorm ail) || empty($notes )) {
echo "<h2>Use Back - fill in all fields</h2>\n";
}
=============== ===========CONT ACT,PHP======== =============== ======
<table width="100%" cellpadding="5" border="2">
<tr><td><form method="post" action="sendema il.php">
<?php
$ipi = getenv("REMOTE_ ADDR");
$httprefi = getenv ("HTTP_REFERER" );
$httpagenti = getenv ("HTTP_USER_AGE NT");
?>
<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="visitorma il" 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(!$visitormai l == "" && (!strstr($visit ormail,"@") || !
strstr($visitor mail,".")))
{
echo "<h2>Use Back - Enter valid e-mail</h2>\n";
$badinput = "<h2>Feedba ck was NOT submitted</h2>\n";
echo $badinput;
}
if(empty($visit or) || empty($visitorm ail) || 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@your site.com", $subject, $message, $from);
?>
<table width=100% cellpadding="10 " border="2">
<tr>
<th align="center"> <h3Confirmati on 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========= =============== ======
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(!$visitormai l == "" && (!strstr($visit ormail,"@") || !
strstr($visitor mail,".")))
{
echo "<h2>Use Back - Enter valid e-mail</h2>\n";
$badinput = "<h2>Feedba ck was NOT submitted</h2>\n";
echo $badinput;
}
if(empty($visit or) || empty($visitorm ail) || empty($notes )) {
echo "<h2>Use Back - fill in all fields</h2>\n";
}
=============== ===========CONT ACT,PHP======== =============== ======
<table width="100%" cellpadding="5" border="2">
<tr><td><form method="post" action="sendema il.php">
<?php
$ipi = getenv("REMOTE_ ADDR");
$httprefi = getenv ("HTTP_REFERER" );
$httpagenti = getenv ("HTTP_USER_AGE NT");
?>
<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 ?
>" />
<input type="text" name="visitor" size="35" />
<br />
Your Email Address:<br />
<input type="text" name="visitorma il" 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(!$visitormai l == "" && (!strstr($visit ormail,"@") || !
strstr($visitor mail,".")))
{
echo "<h2>Use Back - Enter valid e-mail</h2>\n";
$badinput = "<h2>Feedba ck was NOT submitted</h2>\n";
echo $badinput;
}
if(empty($visit or) || empty($visitorm ail) || 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@your site.com", $subject, $message, $from);
?>
<table width=100% cellpadding="10 " border="2">
<tr>
<th align="center"> <h3Confirmati on 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========= =============== ======
Comment