Question

customized my own mailing script. php newbie here so please bear with me. here's the code. I just want to add stripslashes onto the subject and the message, and if so wouldn't it remove also the slashes I made with \r\n\r\n?

$headers="From: {$email}\r\nReply-To: {$email}"; //create headers for email
$content="Name: ".$name."\r\n\r\nCompany: ".$company."\r\n\r\n
Subject: ".$subject."\r\n\r\n
Message: ".$message;
mail('opps@gmail.com',$subject,$content,$headers); //mail the message;
$success = "Thank you! You're email has been sent.";
#done;

Can anyone show me where to put the stripslashes for subject and message? Thanks guys!

Was it helpful?

Solution

$email = stripslashes($email);
$name = stripslashes($name);
$company = stripslashes($company);
$subject = stripslashes($subject);
$message = stripslashes($message);

$headers="From: {$email}\r\nReply-To: {$email}"; //create headers for email
$content="Name: ".$name."\r\n\r\nCompany: ".$company."\r\n\r\n
Subject: ".$subject."\r\n\r\n
Message: ".$message;
mail('opps@gmail.com',$subject,$content,$headers); //mail the message;
$success = "Thank you! You're email has been sent.";
#done;

OTHER TIPS

Follow below code :

  "Subject: ".stripslashes($subject)."\r\n\r\n
  Message: ".stripslashes($message);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top