Hello,
I am having trouble with a php mail form script. When i submit the form on the html page I am taken to the email.php page, but it is blank instead of having the specified thank you text. In addition to that, the info in the form is not e-mailed. I have included the code for the form and the email.php I am using. Thanks for your time.
Warm regards,
Jason D
form:
<form method="post" action="http://www.ecstatix.com/email.php">
<!-- Full name of user -->
<P><font size="-1">Your full name:</font><BR>
<INPUT TYPE="text" NAME="name" SIZE="30">
<!-- Take email addresses with a grain of salt! -->
<P><font size="-1">Your email address: (e.g.: <EM>you@aol.com</EM>)</font><BR>
<INPUT TYPE="text" NAME="from" SIZE="30">
<!-- INSERT ADDITIONAL FORM FIELDS HERE: -->
<P><font size="-1">Your phone number:</font><BR>
<!-- Text Box: Phone Number -->
<INPUT TYPE="text" NAME="Phone Number" VALUE="" SIZE="30" MAXLENGTH="">
<P><font size="-1">Your organization's name:</font><BR>
<!-- Text Box: business -->
<INPUT TYPE="text" NAME="business" VALUE="" SIZE="30" MAXLENGTH="">
<P><font size="-1">Your questions or comments:</font><BR>
<!-- Comment Box: Comment Box -->
<TEXTAREA NAME="Comment Box " ROWS="10" COLS="30" WRAP="hard"></TEXTAREA>
<!-- Submit Button -->
<P><INPUT TYPE="submit" NAME="Submit Button" VALUE="Send to Ecstatix">
<!-- Reset Button -->
<P>
<INPUT TYPE="reset" VALUE="Clear Form">
</FORM>
email.php page:
<?php
#
NL-PHPMail v1.5
First released December 11, 2002
This version released October 6, 2003
#
NL-PHPMail v1.5 is linkware and can be used or modified as long as this note remains intact
and unaltered, and there is a link up back to http://codegrrl.com/ so people know where you got this script. You are forbidden to sell or distribute the code of NL-PHPMail v1.5, in whole
or part, without the written consent of Sasha.
#
By using NL-PHPMail v1.5 you agree to indemnify Sasha from any liability.
#
#
// -----------------------
//VARIABLES NEEDED FOR THE SCRIPT TO WORK, PLEASE CHANGE THESE AS SPECIFIED
// -----------------------
//Your email address (where the form will be sent):
$recipient = 'jd60131@appstate.edu';
//The subject of the email:
$subject = 'Ecstatix Contact Form';
//Change this to the URL to your HTML form.
$form_url = 'http://www.ecstatix.com/contact.html';
//If you're using Headers and Footers with PHP, please fill in the path to them below. This can be a relative path (like, header.inc if it's in the same directory), or an absolute path. If you're NOT using headers, please leave this empty.
$header ='';
$footer ='';
//Below is the content of the actual email sent to you. If you have different or more form fields than specified here, copy and paste the below line (without the // in front of it) into the coding bit below. Beneath the Comments line would be a good place for it:
// $msg .= "Field Description: $POST[field_name]\n";
// Change the description and field name to match the field in your form. The $POST[field_name] variable is what takes the contents of the form fields, so change "field_name" to the name of your form field. The . in front of the = sign merely means that line will be added to the variable, along with all previous lines, instead of overwriting it, so don't take it out! Use \t to insert a tab, and \n to insert a new line.
$msg = "---------------\n";
$msg .= "$subject\n";
$msg .= "---------------\n\n";
$msg .= "Name: $POST[name]\n";
$msg .= "E-Mail: $POST[from]\n";
$msg .= "Phone Number: $Post[Phone Number]\n";
$msg .= "Organization name: $POST[business]\n";
$msg .= "Comments: $_POST[Comment Box]\n";
$msg .= "Sender IP Address: $REMOTE_ADDR\n";
// Change the names below to the 3 required fields in your form. If these fields are not filled out, the script will not send an email and display an error message instead, asking the visitor to fill out the form again.
$req1 ="$name";
$req2 ="$from";
$req3 ="$Comment Box";
//The below error message will be displayed if not all required fields are filled in. Feel free to use normal HTML in this.
$error_required = '<p>It appears you forgot to enter either your email address, your name or your comments. Please press the BACK button in your browser and try again.</p>';
//The below error message will be displayed if the visitor submitted an invalid email address. Feel free to use normal HTML in this.
$error_email = '<p>Oops, it appears that the email address you filled in is not a valid one. Please press the back button on your browser and try again. Please check carefully that you filled in all information in the right fields!</p>';
//The below success message will be displayed when the form is sent. Feel free to use normal HTML in this.
$success_message = '<p>Your information has been sent to Ecstatix Web Design. We will email you back as soon as possible. 🙂</p>';
// -----------------------
//DO NOT EDIT ANYTHING BELOW UNLESS YOU KNOW WHAT YOU'RE DOING!!
// -----------------------
if ($header ==""){
$use_headers ='0';
$header = '<html><head><title>Feedback Form</title></head><body>';
} else {$use_headers ='1';}
if ($footer ==""){
$use_footers ='0';
$footer = '<div align="center"><a href="http://codegrrl.com/" target="_blank"><img src="phpmail.gif" width="80" height="15" alt="Powered by NL-PHPMail" border="0" /></a></div></body></html>';
} else {$use_footers ='1';}
function is_valid_email ($address) {
return (preg_match(
'/[-!#$%&\'*+\.\/0-9=?A-Z_{|}~]+'.
'@'.
'([-0-9A-Z]+\.)+' .
'([0-9A-Z]){2,4}$/i',
trim($address)));
}
function is_valid_email_eregi ($address) {
return (eregi(
'^[-!#$%&\'*+\\./0-9=?A-Z^_{|}~]+'.
'@'.
'([-0-9A-Z]+.)+' .
'([0-9A-Z]){2,4}$',
trim($address)));
}
if (!isset($req1) || !isset($req2) || !isset($req3)) {
header( "Location: $form_url" ); }
elseif (empty($req1) || empty($req2) || empty($req3)) {
if ($use_headers =="0"){
echo "$header";
} else { include ("$header"); }
?>
<h2>Error</h2>
<?=$error_required?>
<?
if ($use_footers =="0"){
echo "$footer";
} else { include ("$footer"); }
}
else {
$f_email = $_POST[email];
$f_email = strtolower(trim($f_email));
if (is_valid_email($f_email)) {
$msg .= "\n\n---------------\n";
$msg .= "NL-PHPMail v1.5 - http://codegrrl.com/\n";
$msg .= "---------------\n\n";
$mailheaders = "MIME-Version: 1.0 \n";
$mailheaders .= "Content-type: text/plain; charset=iso-8859-1 \n";
$mailheaders .= "From: \"$POST[email]\" <$POST[email]> \n";
$mailheaders .= "Reply-To: \"$POST[email]\" <$POST[email]> \n";
$mailheaders .= "X-Priority: 3 \n";
$mailheaders .= "X-MSMail-Priority: High \n";
$mailheaders .= "X-Mailer: PHP4";
mail($recipient, $subject, $msg, $mailheaders);
if ($use_headers =="0"){
echo "$header";
} else { include ("$header"); }
?>
<h2>Thank You, <?=$name?></h2>
<?=$success_message?>
<?
if ($use_footers =="0"){
echo "$footer";
} else { include ("$footer"); }
} else {
if ($use_headers =="0"){
echo "$header";
} else { include ("$header"); }
?>
<h2>Error</h2>
<?=$error_email?>
<?
if ($use_footers =="0"){
echo "$footer";
} else { include ("$footer"); }
} } ?>email.php page