mattachoo Posted May 6, 2006 Share Posted May 6, 2006 [code]// multiple recipients$to = $_POST['to'];// subject$subject = $_POST['subject'];// message$message = $_POST['message'];$headers = 'MIME-Version: 1.0' . "\r\n";$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";//from$from = $_POST['from'];$headers .= 'From: '.$from. "\r\n";// Mail itif (mail($to, $subject, $message, $headers)) { echo '<h1>Success</h1>';} else { echo 'Failure';}[/code]Now, my question is, that whenever I have apostrophes (') in the subject or message, they automatically get slashes (\) added to them. Is there a way that I can turn this off? So when I get the email, the Subject will have an apostrophe without a slash (\) ? Link to comment https://forums.phpfreaks.com/topic/9211-email-help/ Share on other sites More sharing options...
Stuie_b Posted May 7, 2006 Share Posted May 7, 2006 try the following code[code]// multiple recipients$to = $_POST['to'];// subject$subject = stripslashes($_POST['subject']); //Will remove the Slashes added by Magic Quotes and give you a clean subject// message$message = $_POST['message'];$headers = 'MIME-Version: 1.0' . "\r\n";$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";//from$from = $_POST['from'];$headers .= 'From: '.$from. "\r\n";// Mail itif (mail($to, $subject, $message, $headers)) { echo '<h1>Success</h1>';} else { echo 'Failure';}[/code][b][!--coloro:#FF0000--][span style=\"color:#FF0000\"][!--/coloro--]Be careful!! Removing Slashes could be a potential security risk, it also doesn't prevent your script from being hijacked by code injection![!--colorc--][/span][!--/colorc--][/b]hope it helpsStuie Link to comment https://forums.phpfreaks.com/topic/9211-email-help/#findComment-33952 Share on other sites More sharing options...
wildteen88 Posted May 7, 2006 Share Posted May 7, 2006 If your POSTed data is having there quotes escaped (\" or \') then you PHP setup has magic quotes enabled which escapes quotes automatically for you.You can temporarly disable magic quotes for your script by adding the following to the top of your php script:[code]?<?phpif (get_magic_quotes_gpc()){ set_magic_quotes_runtime(0);}?>[/code]That should temporarly shutdown magic quotes. Link to comment https://forums.phpfreaks.com/topic/9211-email-help/#findComment-34041 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.