Jump to content

[SOLVED] Sendmail.php help


atnixon

Recommended Posts

Hello folks..

 

Am new to php, and i am trying to get a feedback form submission working from my website.

 

Here is the basic sendmail.php code.

 

<?php 
$title = $_REQUEST['title']; 
$name = $_REQUEST['name']; 
$street = $_REQUEST['nstreet']; 
$zip = $_REQUEST['zip']; 
$city = $_REQUEST['city']; 
$country = $_REQUEST['country']; 
$phone = $_REQUEST['phone']; 
$email = $_REQUEST['email']; 
$website = $_REQUEST['website']; 
$subject = $_REQUEST['subject']; 
$reply = $_REQUEST['reply']; 
$message = "The Feedback Form 
From: $email 
Title: $title
First Name: $name 
Street: $street,  
Zip: $zip 
City: $city  
Country: $country 
Phone: $phone
Email: $email
Website: $website

mail( "[email protected]", "Feedback Form Results", $message "From: $email" );
  header( "Location: http://www.blogs.com/Thankyou.html" );
?> 

 

Upon submitting the feedback form, i am getting the following error..

 

Parse error: syntax error, unexpected T_STRING in D:\Inetpub\Vhosts\aztecwebdesign.co.uk\httpdocs\sendmail.php on line 25

 

Line 25 in the php code is

 

mail( "[email protected]", "Feedback Form Results", $message "From: $email" );

 

Can anyone help me please? also, am i doing this completely wrong?

 

Regards...

Link to comment
https://forums.phpfreaks.com/topic/125458-solved-sendmailphp-help/
Share on other sites

you have declared

 

$message = "

 

then written some string and did not put the closing ". As variable declartion are like $foo = "blahblah";

 

You should also add a semicolon after double quote.

 

Thank you so much for explain that too me. Works a treat...

added a feature that will tell you if it fails sending the e-mail:

<?php 
$title = $_REQUEST['title']; 
$name = $_REQUEST['name']; 
$street = $_REQUEST['nstreet']; 
$zip = $_REQUEST['zip']; 
$city = $_REQUEST['city']; 
$country = $_REQUEST['country']; 
$phone = $_REQUEST['phone']; 
$email = $_REQUEST['email']; 
$website = $_REQUEST['website']; 
$subject = $_REQUEST['subject']; 
$reply = $_REQUEST['reply']; 

$message = "The Feedback Form\n 
From: $email \n
Title: $title\n
First Name: $name \n
Street: $street,  \n
Zip: $zip \n
City: $city  \n
Country: $country \n
Phone: $phone\n
Email: $email\n
Website: $website";

if (mail( "[email protected]", "Feedback Form Results", $message, "From: $email" )){
header( "Location: http://www.blogs.com/Thankyou.html" );
}
else{
echo "There was an error sending your message. Please contact the site Administrator.";
}
?> 

You were willing to do the work, instead of asking for us to write it for you, so I figured I'd go the extra mile.

added a feature that will tell you if it fails sending the e-mail:

<?php 
$title = $_REQUEST['title']; 
$name = $_REQUEST['name']; 
$street = $_REQUEST['nstreet']; 
$zip = $_REQUEST['zip']; 
$city = $_REQUEST['city']; 
$country = $_REQUEST['country']; 
$phone = $_REQUEST['phone']; 
$email = $_REQUEST['email']; 
$website = $_REQUEST['website']; 
$subject = $_REQUEST['subject']; 
$reply = $_REQUEST['reply']; 

$message = "The Feedback Form\n 
From: $email \n
Title: $title\n
First Name: $name \n
Street: $street,  \n
Zip: $zip \n
City: $city  \n
Country: $country \n
Phone: $phone\n
Email: $email\n
Website: $website";

if (mail( "[email protected]", "Feedback Form Results", $message, "From: $email" )){
header( "Location: http://www.blogs.com/Thankyou.html" );
}
else{
echo "There was an error sending your message. Please contact the site Administrator.";
}
?> 

You were willing to do the work, instead of asking for us to write it for you, so I figured I'd go the extra mile.

 

WOW...thank you very much indeed..I'll tag that to my php now. Yes, i prefer to do the work myself if i can, i find that its the best way to learn..well, works for me anyways...he he he

 

I cant believe it was something as simple as the quotation mark missing.

 

Thanks for the help everyone.

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.