phpmailerstripslashes

How to add striplashes onto my php mail script


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!


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;