email - PHP Mail adding \ if there's a " or ' in the variables -
i've made email script sends users information filled out in our forms. noticed when send information using " or ' adds \' or \" email. understand php requires \'s keep breaking prematurely there way around this?
here's example of issue... daugherty\'s contruction
//send email name@website.com $to = "name@website.com"; $subject = "sending company name - receipt " . $_post['company']; $header = "from: name@website.com" . "\r\n"; $header .= "reply-to: " . $_post['email'] . "\r\n"; $header .= "mime-version: 1.0" . "\r\n"; $header .= "content-type: text/html;charset=iso-8859-1" . "\r\n"; $message = "<html> <body> <img alt='logo' src='http://www.website.com/logo.png'/> <h2> customer payment </h2> <p><b>company: </b>" . $_post["company"] . "</p> <p><b>name: </b>" . $_post['first_name'] . " " . $_post['last_name'] . "</p> <p><b>email: </b>" . $_post['email'] . "</p> <p><b>phone: </b>" . $_post['phone'] . "</p> <p><b>location: </b>" . $_post['city'] . ", " . $_post['state'] . " " . $_post['zip'] . "</p> <p><b>date: </b>" . $today = date('f j, y - g:i (t)') . "</p> <p><b>card used: </b> xxxx-xxxx-xxxx-" . $last4 . "</p> <p><b>payment amount: </b>$" . $_post['price'] . "</p> <br/> <p>http://www.website.com/payment</p> </body> </html>"; mail($to, $subject, $message, $header);
as others have commented because have magic quotes enabled. should disable or can process inputs fix problem, like.
<?php function fix_magic_quotes_gpc(&$value, $key){ if (get_magic_quotes_gpc()) { $value = stripslashes($value); $key = stripslashes($key); } } $inputs = array(&$_get, &$_post, &$_cookie, &$_request); array_walk_recursive($inputs, 'fix_magic_quotes_gpc'); ?>
Comments
Post a Comment