Results 1 to 5 of 5
Thread: PHP Email Script Help
-
12-12-2010, 05:05 AM #1Web Hosting Evangelist
- Join Date
- Jun 2006
- Location
- NY
- Posts
- 485
PHP Email Script Help
I have this php script, and i set it so the email that is entered in the contact form, is the email that it is sentfrom when it is recieved in the inbox.
I set it asPHP Code:$EmailFrom = "".$Email."";
If i were to replace thePHP Code:$EmailFrom = "".$Email."";
PHP Code:$EmailFrom = "email@email.com";
The script is below.
PHP Code:<div id="contactform">
<form method="post" action="contactengine.php">
NAME:
<input type="text" name="Name" id="Name" size="50" maxlength="18" />
<br />
EMAIL:
<input type="text" name="Email" id="Email" size="50" maxlength="18" />
<br />
Message:
<textarea name="Message" id="Message" cols="30" rows="3" maxlength="240" ></textarea>
<input type="Submit" name="submit" value="Submit" />
</form>
</div>
PHP Code:<?php
$EmailFrom = "".$Email."";
$EmailTo = "email@email.com";
$Subject = "You have been contacted";
$Name = Trim(stripslashes($_POST['Name']));
$Email = Trim(stripslashes($_POST['Email']));
$Message = Trim(stripslashes($_POST['Message']));
// validation
$validationOK=true;
if (!$validationOK) {
print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
exit;
}
// prepare email body text
$Body = "";
$Body .= "Name: ";
$Body .= $Name;
$Body .= "\n";
$Body .= "Email: ";
$Body .= $Email;
$Body .= "\n";
$Body .= "Message: ";
$Body .= $Message;
$Body .= "\n";
// send email
$success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>");
// redirect to success page
if ($success){
print "<meta http-equiv=\"refresh\" content=\"0;URL=contactthanks.php\">";
}
else{
print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
}
?>
Thanks
-
12-12-2010, 07:21 AM #2WHT Addict
- Join Date
- Jan 2010
- Location
- Sweden
- Posts
- 130
Where is $Email coming from in this line?
Code:$EmailFrom = "".$Email."";
Please do the needful..
-
12-12-2010, 11:58 AM #3Newbie
- Join Date
- Nov 2010
- Location
- Florida
- Posts
- 21
dubdub is right, this is the problem. All you have to do is move that line to below the line where $Email is declared.
PHP Code:$EmailTo = "email@email.com";
$Subject = "You have been contacted";
$Name = Trim(stripslashes($_POST['Name']));
$Email = Trim(stripslashes($_POST['Email']));
$Message = Trim(stripslashes($_POST['Message']));
$EmailFrom = "".$Email."";
P.S.
The quotes are kind of extraneous.
Instead of:
PHP Code:$EmailFrom = "".$Email."";
PHP Code:$EmailFrom = $Email;
Last edited by HostForMe; 12-12-2010 at 12:09 PM.
██ HostFor.Me — Experienced Customer Care & Support
██ To us, hosting your website means more than simply providing web space on a server.
██ Friendly services include: website design, development, marketing, troubleshooting, and advice.
www.hostfor.me
-
12-12-2010, 09:51 PM #4Web Hosting Evangelist
- Join Date
- Jun 2006
- Location
- NY
- Posts
- 485
This is great!!!!
Thank you so much
-
12-12-2010, 09:59 PM #5Web Hosting Evangelist
- Join Date
- Jun 2006
- Location
- NY
- Posts
- 485
Thanks, i like this one though its the most simple i could find lol and i dont need anything better.
Similar Threads
-
PHP email script
By jasonyyd in forum Programming DiscussionReplies: 2Last Post: 08-15-2010, 08:27 PM -
php welcome email script
By kipper01 in forum Reseller HostingReplies: 5Last Post: 10-11-2009, 11:49 AM -
PHP Email Script
By Adrnalnrsh in forum Programming DiscussionReplies: 3Last Post: 02-18-2005, 03:14 PM -
free php eMail script
By ws19 in forum Programming DiscussionReplies: 2Last Post: 12-18-2004, 03:17 PM -
Email Forward To PHP Script...
By Zoosushi in forum Programming DiscussionReplies: 4Last Post: 01-08-2003, 09:16 AM