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
https://forums.phpfreaks.com/topic/68838-solved-get_magic_quotes_gpc-problem/
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?

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.

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.