Latest News
Arkieprince Blog

Not a John
or a Crapper

Fishing Tips
by Arkieprince

Tutorial Index
List of the Latest Tutorials

CGI 101
CGI Script Installation 101

Java Lake
Java Examples for Lake Class, snow, etc

HTML Generator
Basic CSS HTML Code Generator

CSS Tutorial
External Style Sheet Tutorial

CSS Template
HTML CSS Tableless 3 Column Layout

Plans
IBDhost Rates
Plans

PayPal Donation
Tutorial

HOA or NA
Association

Design Rules
For Web Sites

Demo Page
PHP templates and photo album

Custom 404
PHP code for a custom 404 page

Contact Form
Free PHP Contact Us Form Tutorial
(Current)

Optimize Images
For Web Page Sites

Thumbnail Tutorial
Creating Thumbnails for Web Sites

PHP Template
Free PHP Tutorial

Newsletter Template
Free Template

HTML Basic
Basic HTML Web Page Code

URL Paths
Absolute vs. Relative Path

Submit Sites
to Search Engines

Calculate Bandwidth
Calculator for Monthly Usage

Register Domain
Tutorial (Godaddy)

Mail Help
Outlook Express Email Setup

FTP Help
WS-FTP LE Setup Help

Domain
Sign Up Now

Initial Setup
Startup n Setup Instructions

Featured Sites
Hosting Client Sites

Specials
IBDhost Hosting Specials

TOS
Terms of Service (TOS)

Contact Us
Email Contact Form
(Current)

Home Page
IBDhost Webhost Homepage

Updated:
Sep 17, 2009

© 2002 - 2009
Little Rock
Arkansas

 

spacer
spacer

 

 

 

IBDhost Contact Form (PHP Contact Us)
With A Free PHP Email Script
Free Contact Form Code

Latest Update
Since register_globals are now off by default - convert variables to superglobals.
Form blocks sending of a 'clickable' link i.e. form blocks spam that contains an URL / 'hot' link!

All fields required ! Name:

Email:

Contact form in demo mode!

Attention:


Mail Message:

Box code from: CSS Form Layouttutorial.

Bonus Tutorial
Email Form
n 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 :) 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.



E-mail Form Code (contact.php)

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "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: <br />
<input type="text" name="visitor" size="35" />
<br />
Your Email:<br />
<input type="text" name="visitormail" size="35" />
<br /> <br />
<br />
Attention:<br />
<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>
<br /><br />
Mail Message:
<br />
<textarea name="notes" rows="4" cols="40"></textarea>
<br />
<input type="submit" value="Send Mail" />
<br />
</form>

</body>
</html>



Code for sendeail.php

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "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 (eregi('http:', $notes)) {
die ("Do NOT try that! ! ");
}
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 ?>
<br />
Thank You : <?php echo $visitor ?> ( <?php echo $visitormail ?> )
<br />

Attention: <?php echo $attn ?>
<br />
Message:<br />
<?php $notesout = str_replace("\r", "<br/>", $notes);
echo $notesout; ?>
<br />
<?php echo $ip ?>

<br /><br />
<a class="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.


Check PHP / Safe Mode

How to check that PHP is running and that Safe Mode is OFF !

Use notepad (or other text editor) create an ASCII text file with this line:

<?php phpinfo() ?>

Save that file as test.php
Must be a text file with .php extension - NOT test.php.txt

Upload test.php (as ASCII file) - to the server

Run test.php from the browser
e.g. www.domain.com/test.php

This will display all the php settings. Use 'find' to check the 'safe' mode section to make sure it is OFF. e.g. look under the Configuration PHP Core Table in the Directive column to see that safe mode is off.


Easy method to convert form variables to superglobals in ANY form:

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


gipoco.com is neither affiliated with the authors of this page nor responsible for its contents. This is a safe-cache copy of the original web site.