Malioglasnik.com.hr

[ New messages · Members · Forum rules · Search · RSS ]
  • Page 1 of 1
  • 1
Forum » Web Design » PHP » Contact Form (PHP Contact Us) With A Free PHP Email Script
Contact Form (PHP Contact Us) With A Free PHP Email Script
BassoDate: Saturday, 2011-02-05, 11:54 AM | Message # 1
Group: Moderator
Messages: 1637
Awards: 2
Reputation: 695
Status: Offline

Bonus Tutorial Email Form and PHP Script


The advantage of sending contact email with a php form is that your email address is hidden from spam robots ... that look for 'mailto' in the code.


Required: A PHP host that does NOT block mail() and has safe_mode OFF.


Improvement: Since register globals are often OFF by default - the script now converts all form variables to superglobals - inside the output (sendeail.php) script


VIP: If you have problems, BE SURE to make a test.php and run it - to determine your php settings (see notes)


Alert: To prevent spammers using your form - make sure that your web host blocks the BCC function (best protection). If this is not possible, use php code in the sendeail.php to filter out the 'return' and the "line breaks" (use google search to find code)


Other Features
PHP Script hides your email address i.e. no email address in the form.
PHP Script checks for required email (format) & blanks! !
Copy n Paste section now includes code to validate to XTHML 1.0


Overview: This free email contact script includes a check for blank fields and a check for the correct email format i.e. more POWER - all using PHP (NO JAVASCRIPT REQUIRED smile And now the output file (sendeail.php) blocks 'links' e.g. URL code is blocked so spammers can Not send 'hot' links.
For form code that includes more options - types of input, visit the Feedback Form tutorial.


Step 1: Copy and paste the e-mail Form Code into a 'contact.php' page (must be a html/php page on a server that allows php!).


Step 2: Copy n paste the sendeail.php code into a new file. Change the YourEmail section to include your email address. Then check (or modify) the link at the bottom (contact.php) to point to the desired Next Page. Save the file as 'sendeail.php' (as ASCII file).


Step 3: Upload both files as ASCII i.e. upload the same way as .html files. Be sure both files are in the same folder on the server.
 
If you have a problem about Intellectual property rights violation,

Please Contact Us we remove all content within 24 hours.



BassoDate: Saturday, 2011-02-05, 11:55 AM | Message # 2
Group: Moderator
Messages: 1637
Awards: 2
Reputation: 695
Status: Offline

E-mail Form Code (contact.php)
Code
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Email Form </title>
</head>
<body>

<form method="post" action="sendeail.php">

<!-- DO NOT change ANY of the php sections -->
<?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:

<input type="text" name="visitor" size="35" />


Your Email:

<input type="text" name="visitormail" size="35" />





Attention:

<select name="attn" size="1">
<option value=" Sales n Billing ">Sales n Billing </option>
<option value=" General Support ">General Support </option>
<option value=" Technical Support ">Technical Support </option>
<option value=" Webmaster ">Webmaster </option>
</select>



Mail Message:


<textarea name="notes" rows="4" cols="40"></textarea>


<input type="submit" value="Send Mail" />


</form>

</body>
</html>
 
If you have a problem about Intellectual property rights violation,

Please Contact Us we remove all content within 24 hours.



BassoDate: Saturday, 2011-02-05, 11:57 AM | Message # 3
Group: Moderator
Messages: 1637
Awards: 2
Reputation: 695
Status: Offline

Code for sendeail.php
Code
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Sendemail Script</title>
</head>
<body>

<!-- Reminder: Add the link for the 'next page' (at the bottom) -->
<!-- Reminder: Change 'YourEmail' to Your real email -->

<?php

$ip = $_POST['ip'];
$httpref = $_POST['httpref'];
$httpagent = $_POST['httpagent'];
$visitor = $_POST['visitor'];
$visitormail = $_POST['visitormail'];
$notes = $_POST['notes'];
$attn = $_POST['attn'];

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;
die ("Go back! ! ");
}

if(empty($visitor) || empty($visitormail) || empty($notes )) {
echo "<h2>Use Back - fill in all fields</h2>\n";
die ("Use back! ! ");
}

$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("YourEmail", $subject, $message, $from);

?>

<p align="center">
Date: <?php echo $todayis ?>


Thank You : <?php echo $visitor ?> ( <?php echo $visitormail ?> )



Attention: <?php echo $attn ?>


Message:

<?php $notesout = str_replace("\r", "<br/>", $notes);
echo $notesout; ?>


<?php echo $ip ?>




<a href="contact.php"> Next Page </a>
</p>

</body>
</html>

Note: You MUST modify the YourEmail Address and the link (contact.php)!!!

BTW: Some web host block the mail() function if the 'from email' is not from your domain. In other words: sometimes, the domain email address must be used - or the mail() function will not work.
P.S. Google search for 'CAPTCHA php email scripts' will show captcha scripts that you can include.

 
If you have a problem about Intellectual property rights violation,

Please Contact Us we remove all content within 24 hours.



Forum » Web Design » PHP » Contact Form (PHP Contact Us) With A Free PHP Email Script
  • Page 1 of 1
  • 1
Search:
Forum Advice
Security advice: Protect your identity when downloading!
Your real identity and ip address is visible while downloading. These days, everyone's looking to throttle your connection, spy on what you're downloading, or even send you an ominous letter. If you use BitTorrent, you absolutely need to take precautions to hide your identity. An easy and raliable solution is a VPN by hide.me. Hide.me doesn't store any logs and offers blazing fast connections.Hide.me VPN is trustedby more than 500.000 internet users worldwide and recommended by Brna.my1.ru.