Forum Moderators: coopster
I have ceated a simple mail script and was wondering if someone can help me find an error in the code.
I am getting an error on line 4 which is an unexpected T_VARIABLE i have had these before and its usually a space on the <?php or missing a curly brace or semi-colon, but a cannot see that in this.
Can anyone notice anything or am i just being stupid?
Many Thanks
<?php
$to = "email goes here";
$subject = "Contact form";
$message = "From:"$_REQUEST['name']"<br><br> Reply E-mail:"$_REQUEST['email']"<br><br> Telephone Number:"$_REQUEST['tel']"<br><br> Current Job Title:"$_REQUEST['jobtitle']"<br><br> Current Employer:"$_REQUEST['employer']"<br><br> Does this person wish to be contacted:"$_REQUEST['contact'];
$headers = "From: $email";
$sent = mail($to, $subject, $message, $headers) ;
if($sent)
{print "Congrats"; }
else
{print "We encountered an error sending your mail"; }
?>
// changes here
$message = "From:" . $_REQUEST['name'] . "<br><br> Reply E-mail:" . $_REQUEST['email'] . "<br><br> Telephone Number:" . $_REQUEST['tel'] . "<br><br> Current Job Title:" . $_REQUEST['jobtitle'] . "<br><br> Current Employer:" . $_REQUEST['employer'] . "<br><br> Does this person wish to be contacted:" . $_REQUEST['contact'];
// end changes
Also I know you're just trying to get this to work, but I hope you are filtering $_REQUEST before putting them in your program, this is a recipe for email injection.
How do you mean?
Are you referring to my comment about filtering?
Do a search for this:
email injection site:webmasterworld.com
There are hundreds of ways to abuse mailers to send spam. A hacker doesn't even need to visit your form, they just need to know the location of your form processor and they can post data to it via command line.
Did the concatenation work? It should . . .