Jump to content

[SOLVED] get_magic_quotes_gpc problem


jas4

Recommended Posts

Hi i'm trying to send an email using data collected through a post form. Problem is when it comes to the email message and things like

<img src="link.gif">

 

here is the code I've got at the moment:

 

$message1 = $_POST['emailMessage']; <---the posted form data that is the body

 

that send something through like this:

 

<p>this is another = <strong>have some bold</strong></p>
<p><img src="http://www.google.co.uk/intl/en_uk/images/logo.gif" alt="" /></p>

 

So I put message 1 through this piece of code:

 

if ( get_magic_quotes_gpc() )
	$message = htmlspecialchars( stripslashes( $message1 ) ) ;
else
	$message = htmlspecialchars( $message1 ) ;

 

and $message returns code like this

 

<p>SPETthis is another = <strong>have some bold</strong></p> <p>
<img src="http://www.google.co.uk/intl/en_uk/images/logo.gif" alt="alt text" /></p>

 

so now I put $message in the email body, but when I check the code of the email it looks like:

 

<p>SPETthis is another = <strong>have some bold</strong></p>

<p><img alt=\'\' src=\'http://www.google.co.uk/intl/en_uk/images/logo.gif\' /></p><br><Br>

 

and the image does not appear ???

 

 

 

 

Link to comment
Share on other sites

ok so i cut this down...

 

if ( get_magic_quotes_gpc() )
	$message = htmlspecialchars( stripslashes( $message1 ) ) ;
else
	$message = htmlspecialchars( $message1 ) ;

 

to this..

	$message =  stripslashes( $message1 )  ;

 

and it works ;D

 

should I check to see if ( get_magic_quotes_gpc() ) first?

Link to comment
Share on other sites

No, you should have that. Perhaps it's magic_quotes_runtime that is adding the slashes?

You don't have any escape functions on the strings anywhere else?

 

Also if you're trying to send html in the email I think you don't want to use htmlspecialchars.

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.