**** removing slashes

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
igbw
Forum Newbie
Posts: 3
Joined: Mon May 17, 2004 7:48 pm

**** removing slashes

Post by igbw »

I have a form in Flash that I'm sending to a PHP script that is sending an e-mail. My problem is the I keep getting / before all ' I've tried stripslashes($mailMessage); but that doesn't seem to do the trick. Here's my code any help would be appreciated.

-Thanks

note: commented out code of things i've tried
<?

$siteName = "mySite.com";
$siteURL = "http://www.myURL.net";
$siteContact = "my@email.com";
$recipientEmail = "my@email.com";

$mailMessage = "Name: ".$senderName;
$mailMessage .= "\nCompany: ".$company;
$mailMessage .= "\nPhone: ".$phone;
$mailMessage .= "\nE-Mail: ".$eMail;
$mailMessage .= "\nAddress: ".$address;
$mailMessage .= "\nCity: ".$city;
$mailMessage .= "\nState: ".$state;
$mailMessage .= "\nZip: ".$zip;
$mailMessage .= "\nCountry: ".$country;
//stripslashes($mailMessage);
//htmlspecialchars($mailMessage);
//htmlentities($mailMessage);
//echo $mailMessage;

// Build up email header fields
$mailFrom = "From: $siteName <$siteContact>";
$mailTo = "$recipientEmail";
$mailSubject = "Message from $senderName";

// Send email
mail($mailTo, $mailSubject, $mailMessage, $mailFrom);

$response = "Message Sent";

// Respond to Flash movie!
print "&statusDisplay=$response&";

?>
User avatar
dull1554
Forum Regular
Posts: 680
Joined: Sat Nov 22, 2003 11:26 am
Location: 42:21:35.359N, 76:02:20.688W

Post by dull1554 »

why do you have it commented out?
that might help....?!?!?!?!?!

there is no reason that

Code: Select all

stripslashes();
won't work.
User avatar
tim
DevNet Resident
Posts: 1165
Joined: Thu Feb 12, 2004 7:19 pm
Location: ohio

Post by tim »

is it possible that: http://us4.php.net/manual/en/function.g ... es-gpc.php is off? its on by default but it can be off, that will screw up the stripslashes function. (not looking at your code, just giving my .02)
jason
Site Admin
Posts: 1767
Joined: Thu Apr 18, 2002 3:14 pm
Location: Montreal, CA
Contact:

Post by jason »

Use http://ca.php.net/stripslashes

Remember, it RETURNS the string without the slashes. You don't capture that output in your script.
jason
Site Admin
Posts: 1767
Joined: Thu Apr 18, 2002 3:14 pm
Location: Montreal, CA
Contact:

Post by jason »

For those offering help: Please, take the time to read the code and to read the post. It doesn't do anybody any good if you don't take the time to actually test what you are suggesting.

dull1554: Uncommenting stripslashes() won't do anything. I am also sure he had it uncommented before, and was only commented here. Heck, he even says so:
note: commented out code of things i've tried
Finally, igbw: Use the PHP bbCode tags. They will highlight the code for you, and more importantly, for the people trying to help you. By using the bbCode tags, you may spot an error, and it just makes reading the post much easier.

Code: Select all

<?

$siteName = "mySite.com";
$siteURL = "http://www.myURL.net";
$siteContact = "my@email.com";
$recipientEmail = "my@email.com";

$mailMessage = "Name: ".$senderName;
$mailMessage .= "\nCompany: ".$company;
$mailMessage .= "\nPhone: ".$phone;
$mailMessage .= "\nE-Mail: ".$eMail;
$mailMessage .= "\nAddress: ".$address;
$mailMessage .= "\nCity: ".$city;
$mailMessage .= "\nState: ".$state;
$mailMessage .= "\nZip: ".$zip;
$mailMessage .= "\nCountry: ".$country;
//stripslashes($mailMessage);
//htmlspecialchars($mailMessage);
//htmlentities($mailMessage);
//echo $mailMessage;

// Build up email header fields
$mailFrom = "From: $siteName <$siteContact>";
$mailTo = "$recipientEmail";
$mailSubject = "Message from $senderName";

// Send email
mail($mailTo, $mailSubject, $mailMessage, $mailFrom);

$response = "Message Sent";

// Respond to Flash movie!
print "&statusDisplay=$response&";

?>
See, much nicer. =)
User avatar
tim
DevNet Resident
Posts: 1165
Joined: Thu Feb 12, 2004 7:19 pm
Location: ohio

Post by tim »

Sorry jason.

I was just trying to think why stripslashes wouldnt work (as its a pretty straight forward function) and i just thought the magic_quotes need to be on n said what I thought.
User avatar
dull1554
Forum Regular
Posts: 680
Joined: Sat Nov 22, 2003 11:26 am
Location: 42:21:35.359N, 76:02:20.688W

Post by dull1554 »

boy o' boy, i suppose i should look a bit closer before i try to give a answer...........
jason
Site Admin
Posts: 1767
Joined: Thu Apr 18, 2002 3:14 pm
Location: Montreal, CA
Contact:

Post by jason »

No, no need to apologize guys. I didn't mean to sound like I was <span style='color:blue' title='I'm naughty, are you naughty?'>smurf</span>. It's just my job to be anal. =)

The point was to say: Read, write, edit, reread, edit, post. In other words, make sure you read everything, then write your response. Then go back and edit your response for spelling and grammar (yes, spelling and grammar make a big difference), reread what the person wrote, and then what you wrote, edit if you need to, then post.

No harm, no worries.
User avatar
dull1554
Forum Regular
Posts: 680
Joined: Sat Nov 22, 2003 11:26 am
Location: 42:21:35.359N, 76:02:20.688W

Post by dull1554 »

true true...
i'll leave it at that

*its just that sometimes people get careless*
igbw
Forum Newbie
Posts: 3
Joined: Mon May 17, 2004 7:48 pm

Post by igbw »

i tried adding get_magic_quotes_gpc(1); at the top of my code and it didn't work. is that what you all were talking about?

thanks for the help.
jason
Site Admin
Posts: 1767
Joined: Thu Apr 18, 2002 3:14 pm
Location: Montreal, CA
Contact:

Post by jason »

igbw: No, try looking at [php_man]stripslashes[/php_man]($mailMessage); again.

You see, you are just calling the function. But if you look at the manual, [php_man]stripslashes[/php_man] returns something (the cleaned string).

So what you really want is this:

Code: Select all

$mailMessage = stripslashes($mailMessage);
igbw
Forum Newbie
Posts: 3
Joined: Mon May 17, 2004 7:48 pm

Post by igbw »

thanks jason that fixed it.

peace
igbw
Post Reply