Jump to content

How to receive messages with double quotes in place


darrelf

Recommended Posts

I have created a simple form that collects a comment or question from a visitor to my website.

 

The problem is that if the visitor types:

Your site looks Ok.

I will get that message.

 

But if the type: Your site needs "Work".

I will get: Your site needs

 

The script will not send the double quotes or anything after the double quotes

 

What am I missing???

 

I have tried:

addslashes()

str_replace()

preg_replace()

 

with on change to the message.

 

 

 

This is the script

 

<?php

$recipient = $_POST['recipient'];
$subject = $_POST['subject'];
$first_name = $_POST['first_name'];
$last_name = $_POST['last_name'];
$senders_email_address = $_POST['senders_email_address'];
$comments = $_POST['comments'];

$mailheaders .= "To: Thin Dime Web. <$recipient>\n";
$mailheaders .= "From: $first_name $last_name <$senders_email_address>\n";



       $body .= "Subject: $subject\n\n";
       $body .= "Senders Name: $first_name $last_name\n";
       $body .= "E-mail Address: $senders_email_address\n\n";

       $body .= "The following Comments or Question came from a visitor to your website\n";
       $body .= "\n";
       $body .= "$comments\n";


       mail("$recipient", "$subject", "$body", "$mailheaders");

?>

Link to comment
Share on other sites

mysql_real_escape_string($_POST[''])

might do the trick.

Why would the OP need to use that function if they are not using a database!

 

@darrelf If you echo $comments variable just before you send the email does it show the message in full?

$comments = $_POST['comments'];

// preview comments
echo $comments;

Link to comment
Share on other sites

mysql_real_escape_string($_POST[''])

might do the trick.

Why would the OP need to use that function if they are not using a database!

 

@darrelf If you echo $comments variable just before you send the email does it show the message in full?

$comments = $_POST['comments'];

// preview comments
echo $comments;

 

No the message will not show double quotes if I place an echo statement.

Link to comment
Share on other sites

i thought mysql_real_escape_string() would backslash all the quotation marks, just a work around... sorry.

It escapes harmful characters to prevent SQL injection attacks within an SQL query. There is no point in using that function if the data is not going to a database.

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.