Jump to content

Unexpected characters in user message


invictusBob

Recommended Posts

I'm taking a message submitted by the user and sending it via mail() to the site owner. I don't apply any conversions to the string except stripslashes() before mailing. This has worked well except that when anyone uses an @, what gets sent is Å (capital A with ring above). Can I fix this in the PHP script or is the problem on the client side?

 

Link to comment
https://forums.phpfreaks.com/topic/220505-unexpected-characters-in-user-message/
Share on other sites

Thanks for the response, code below:

 

<?php

foreach ($_POST as $key => $value) {

$currField = "";

switch ($key) {

case 'message':

$currField = $value."\n\n";

break;

case 'name':

$currField = "From: ".$value."\n\n";

$fromName = $value;

break;

case 'email':

$currField = "Email: ".$value;

$fromEmail = $value;

break;

}

$message = $currField.$message;

}

$message = stripslashes($message);

 

$to = "info@*******.co.uk";

 

$subject = "Message from ******* website";

$additional_headers = 'From: '.$fromName.' <'.$fromEmail.">\r\n".'Bcc: ***@*******.co.uk';

$mailOK = mail($to, $subject, $message, $additional_headers);

 

if ($mailOK) {

echo 'Message=Thank you, your message has been received.';

}else{

echo "Message=Sorry, your request couldn't be sent at this time, please try later.";

}

 

?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.