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
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.";

}

 

?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.