ballhogjoni Posted April 24, 2008 Share Posted April 24, 2008 I am trying to send html to a variable using a form. I can't figure this out, can some one lead me in the right direction? this is the html code I want to send to a single variable: <center> <a href="https://xxxxxxxxxxxxxxxxxx/index.php"><img src="http://solutionspricing.com/blah/4058/bbbbbbbbbbbb_01.jpg" width="621" height="163" alt="" border=0></a> <table style="border-collapse:collapse;"> <tr> <td> <a href="https://xxxxxxxxxxxxxxxx/index.php"><img src="http://xxxxxxxxxxxxxxxxxx/blah/4058/bbbbbbbbbbbb_02.jpg" width="621" height="163" alt="" border=0></a></td> </tr> <tr> <td> <a href="https://xxxxxxxxxxxxxxxxxxxxx/index.php"><img src="http://xxxxxxxxxxxxxxxxxxxx/blah/4058/bbbbbbbbbbbb_03.jpg" width="621" height="163" alt="" border=0></a></td> </tr> </table> <a href="https://xxxxxxxxxxxxxxxxxxxxxxxx/ibus_unsub.php"><img src="http://xxxxxxxxxxxxxx/blah/4058/xxxxxxxxxx.gif" width="354" height="59" border=0></a> </center> my code so far: <?php //include the database connection variables include('config.php'); //connecting to the database mysql_connect($db_server,$db_user,$db_password) or die(mysql_error()); @mysql_select_db($db_name) or die(mysql_error()); //declaring the variables for later use $fromName = $_POST['fromName']; $fromEmail = $_POST['fromEmail']; $textOrHtml = $_POST['textOrHtml']; $subject = $_POST['subject']; $offer = $_POST['offer']; $mess = $_POST['message']; echo $mess; $unsub_url = $_POST['unsub_url']; $mess2 = "If you wish to cut off communication, visit $unsub_url"; $message = $mess.$mess2; //setting the headers for the mail() $header = "MIME-Version: 1.0\r\n"; $header .= "Content-Type: text/$textOrHtml\r\n"; $header .= "From: $fromName <$fromEmail>\n"; $header .= "Reply-To: $fromEmail\n"; $header .= "Return-Path: $fromEmail\n"; if ($_POST['submitted']) { //query to get emails from the database $query = mysql_query("SELECT email, fname, lname FROM ".$_POST['offer']." WHERE soldProductTo = '0'"); //checking to see if the query brings back any records if (mysql_num_rows($query) > 0) { //using a while loop to extract the records one by one and email each record individually while($row = mysql_fetch_assoc($query)) { extract($row); mail($email,$subject,$message,$header); } echo "The email has been sent to " . mysql_num_rows($query) . " records"; } } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Bulk mail non buyers</title> </head> <body> <form action="" method="POST"> <table> <tr> <td> From Name: </td> <td> <input type="text" name="fromName" /> </td> </tr> <tr> <td> From Email: </td> <td> <input type="text" name="fromEmail" /> </td> </tr> <tr> <td> Text or HTML: </td> <td> <select name="textOrHtml"> <option value="html">HTML</option> <option value="plain">Text</option> </select> </td> </tr> <tr> <td> Email Subject: </td> <td> <input type="text" name="subject" /> </td> </tr> <tr> <td> Message: </td> <td> <textarea name="message" rows="15" cols="60"></textarea> </td> </tr> <tr> <td> Offer: </td> <td> <select name="offer"> <option value="xxxxxxxxx">xxxxx</option> <option value="xxxxxxx">xxxxxxxxx</option> <option value="test">test</option> </select> </td> </tr> <tr> <td> Unsubscribe Link: </td> <td> <select name="unsub_url"> <option value="http://xxxxxxxxxxx/ibus_unsub.php">xxxxxxxxxxxxx</option> <option value="http://xxxxxxxxxxx/unsub.php?action=unsub&email=$email">xxxxxx</option> </select> </td> </tr> <tr> <td colspan="2" align="center"> <input type="hidden" name="submitted" value="submitted"/> <input type="submit" value="Submit" /> </td> </tr> </table> </form> </body> </html> Link to comment https://forums.phpfreaks.com/topic/102629-solved-sending-html-to-a-php-variable/ Share on other sites More sharing options...
947740 Posted April 24, 2008 Share Posted April 24, 2008 My understanding of your question is that you want all of that in one variable. Try this: $variablename = <<<ENDOFTEXT <center> <a href="https://xxxxxxxxxxxxxxxxxx/index.php"><img src="http://solutionspricing.com/blah/4058/bbbbbbbbbbbb_01.jpg" width="621" height="163" alt="" border=0></a> <table style="border-collapse:collapse;"> <tr> <td> <a href="https://xxxxxxxxxxxxxxxx/index.php"><img src="http://xxxxxxxxxxxxxxxxxx/blah/4058/bbbbbbbbbbbb_02.jpg" width="621" height="163" alt="" border=0></a></td> </tr> <tr> <td> <a href="https://xxxxxxxxxxxxxxxxxxxxx/index.php"><img src="http://xxxxxxxxxxxxxxxxxxxx/blah/4058/bbbbbbbbbbbb_03.jpg" width="621" height="163" alt="" border=0></a></td> </tr> </table> <a href="https://xxxxxxxxxxxxxxxxxxxxxxxx/ibus_unsub.php"><img src="http://xxxxxxxxxxxxxx/blah/4058/xxxxxxxxxx.gif" width="354" height="59" border=0></a> </center> ENDOFTEXT; Hopefully I answered your question. Link to comment https://forums.phpfreaks.com/topic/102629-solved-sending-html-to-a-php-variable/#findComment-525598 Share on other sites More sharing options...
ballhogjoni Posted April 24, 2008 Author Share Posted April 24, 2008 the problem is that I enter the html into a textarea and submit the form which should pass the html as a string to a variable on the php page, but for some reason the links and images are being escaped by php or something. Link to comment https://forums.phpfreaks.com/topic/102629-solved-sending-html-to-a-php-variable/#findComment-525659 Share on other sites More sharing options...
Fadion Posted April 24, 2008 Share Posted April 24, 2008 Not sure at all for what im talking, but have u tried htmlentities()? Link to comment https://forums.phpfreaks.com/topic/102629-solved-sending-html-to-a-php-variable/#findComment-525669 Share on other sites More sharing options...
jonsjava Posted April 24, 2008 Share Posted April 24, 2008 is this what you are wanting: <?php $variable = "<center> <a href='https://xxxxxxxxxxxxxxxxxx/index.php'><img src='http://solutionspricing.com/blah/4058/bbbbbbbbbbbb_01.jpg' width='621' height='163' alt='' border=0></a> <table style='border-collapse:collapse;'> <tr> <td> <a href='https://xxxxxxxxxxxxxxxx/index.php'><img src='http://xxxxxxxxxxxxxxxxxx/blah/4058/bbbbbbbbbbbb_02.jpg' width='621' height='163' alt='' border=0></a></td> </tr> <tr> <td> <a href='https://xxxxxxxxxxxxxxxxxxxxx/index.php'><img src='http://xxxxxxxxxxxxxxxxxxxx/blah/4058/bbbbbbbbbbbb_03.jpg' width='621' height='163' alt='' border=0></a></td> </tr> </table> <a href='https://xxxxxxxxxxxxxxxxxxxxxxxx/ibus_unsub.php'><img src='http://xxxxxxxxxxxxxx/blah/4058/xxxxxxxxxx.gif' width='354' height='59' border=0></a> </center>"; ? Link to comment https://forums.phpfreaks.com/topic/102629-solved-sending-html-to-a-php-variable/#findComment-525673 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.