Jump to content

Quotes and Slashes


Edward

Recommended Posts

 

Hi,

 

I've been trying to solve this but to no avail. I know there can be problems with quotes and slashes but I've not had this specific problem before.

 

I have multiple blocks of text (html code) containing double quotes and html tags:

 

$email_content .= '<tr><td width="10" align="left" valign="top" cellpadding="0" cellspacing="0" border="0"></td><td width="120" height="170" align="center" valign="middle" cellpadding="0" cellspacing="0" border="0"><p>Hello</p></td><td width="10" align="left" valign="top" cellpadding="0" cellspacing="0" border="0"></td></tr>';

 

If certain links in the page are clicked on, specific blocks of html become added to the $content variable. I need to be able to email the $content variable via a form. So far I'm using this:

 

//if (get_magic_quotes_gpc())	{
//$email_content = stripslashes($email_content);
//}	
$email_content = urlencode($email_content);
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<p>
<input type="text" name="recipient" value="<?php echo $_POST['recipient']; ?>" size="20" maxlength="100" /><br />
<input type="hidden" name="content" value="<?php echo $email_content; ?>" />
<input type="submit" name="submit_send_short_list" value="e-mail short list" />
</p>
</form>

if (isset($_POST['submit_send_short_list'])) {
//if (get_magic_quotes_gpc())	{
//  	$email_content = stripslashes($_POST['email_content']);	// remove slashes
//}	
$email_content = html_entity_decode($_POST['email_content']);
$body = '<html>'.$email_content.'</body>';
mail($_POST['recipient'], 'my subject', $body);

 

Toggling the above commented codes, I either end up with slashes in the email, or the $email_content row doesn't appear. Can anyone see the best way to fix this?

 

Thank you.

Link to comment
https://forums.phpfreaks.com/topic/57769-quotes-and-slashes/
Share on other sites

not sure if you're 2nd piece of code is as it is in your actual file, but the only php code you have in <?php ?> tags is the values in the form.

 

$email_content = urlencode($email_content);

 

and

 

if (isset($_POST['submit_send_short_list'])) {
//if (get_magic_quotes_gpc())	{
//  	$email_content = stripslashes($_POST['email_content']);	// remove slashes
//}	
$email_content = html_entity_decode($_POST['email_content']);
$body = '<html>'.$email_content.'</body>';
mail($_POST['recipient'], 'my subject', $body);

 

are not.

Link to comment
https://forums.phpfreaks.com/topic/57769-quotes-and-slashes/#findComment-286107
Share on other sites

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.