elmas156 Posted March 26, 2013 Share Posted March 26, 2013 Hello everyone, I'm creating a page that has an html form that has a couple of text areas that I can use to ad text, including special characters and html. This text is being passed to php variables and rendered on the page so that I can view it how the reader will view it. From there I have the option to submit the text to the database for the text to be stored there, or to edit the text, placing it back into text areas by passing the variables via hidden fields and echoing the variables into the "value" area of the form field (<input type="text" name="test" value="<?php echo $variable; ?>" />. The problem that I'm having is that when I enter text including special characters, mainly quotation marks, and then I click the "Edit" button to edit the text further, everything past the first qutation mark is gone. The page I'm working on is located at http://www.bubblybounce.com/test/admin/blogentry.php and the code that I have so far is attached below. Any help would be greatly appreciated. <?php include("../dbconnect.inc.php"); function safe($value){ return mysql_real_escape_string($value); } date_default_timezone_set('America/Chicago'); $cmonth = date("m"); $cday = date("d"); $cyear = date("Y"); $today = "$cmonth/$cday/$cyear"; if (isset($_POST['check'])) { $title = $_POST['title']; $maincontent = $_POST['maincontent']; $sidecontent = $_POST['sidecontent']; $title1 = nl2br($title); $maincontent1 = nl2br($maincontent); $sidecontent1 = nl2br($sidecontent); } elseif (isset($_POST['edit'])) { $title = $_POST['title']; $maincontent = $_POST['maincontent']; $sidecontent = $_POST['sidecontent']; $title1 = nl2br($title); $maincontent1 = nl2br($maincontent); $sidecontent1 = nl2br($sidecontent); } elseif (isset($_POST['done'])) { $title = $_POST['title']; $maincontent = $_POST['maincontent']; $sidecontent = $_POST['sidecontent']; $title1 = safe($title); $maincontent1 = safe($maincontent); $sidecontent1 = safe($sidecontent); $blogresult = mysql_query("SELECT * FROM blog") or die (mysql_error()); $numblog = mysql_num_rows($blogresult); $blognumber = $numblog + 1; $pagename = "blogentry_$blognumber"; copy('blogtemplate.php', '../blog/blogentry_' . $blognumber . '.php'); mysql_query("INSERT INTO `blog` (pagename,title,maincontent,sidecontent,entrydate) VALUES ('$pagename','$title1','$maincontent1','$sidecontent1','$today')") or die (mysql_error()); } ?> <!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" /> <meta name="robots" content="noindex, follow" /> <link rel="shortcut icon" href="images/favicon.ico" /> <link href="../style.css" rel="stylesheet" type="text/css" /> <script type="text/javascript" src="jscript.js"></script> <title>New Bubbly Bounce Blog Entry</title> </head> <body> <div id="container"> <div id="header"> <ul> </ul> </div> <!-- begin body code --> <div id="content"> <?php if (isset($_POST['check'])) { ?> <form name="checkdone" action="blogentry.php" method="POST"> <div id="blogleft"> <img src="../images/eric.png" width="120" /><br /> <font style="color: #999999; font-size: 14px; font-style: italic;">By: Eric Coulston,<br /> <?php echo $today; ?></font> </div> <div id="blogmiddle"> <h6><input type="hidden" name="title" value="<?php echo $title; ?>" /><?php echo $title1; ?></h6> <input type="hidden" name="maincontent" value="<?php echo $maincontent; ?>" /><?php echo $maincontent1; ?> <p><input type="submit" name="edit" value=" Edit... " /> <input type="submit" name="done" value=" Submit... " /></p> </div> <div id="blogright"> <input type="hidden" name="sidecontent" value="<?php echo $sidecontent; ?>" /><?php echo $sidecontent1; ?> </div> </form> <?php } elseif (isset($_POST['edit'])) { ?> <form name="check" action="blogentry.php" method="POST"> <div id="blogleft"> <img src="../images/eric.png" width="120" /><br /> <font style="color: #999999; font-size: 14px; font-style: italic;">By: Eric Coulston,<br /> <?php echo $today; ?></font> </div> <div id="blogmiddle"> <strong>Title:</strong> <input type="text" name="title" value="<?php echo $title; ?>" /> <p><strong>Main Content:</strong><br /> <textarea style="height: 330px; width: 520px;" name="maincontent"><?php echo $maincontent; ?></textarea></p> <input type="submit" name="check" value=" Check... " /> </div> <div id="blogright"> <strong>Side Content:</strong><br /> <textarea style="height: 370px; width: 260px;" name="sidecontent"><?php echo $sidecontent; ?></textarea> </div> </form> <?php } else { ?> <form name="check" action="blogentry.php" method="POST"> <div id="blogleft"> <img src="../images/eric.png" width="120" /><br /> <font style="color: #999999; font-size: 14px; font-style: italic;">By: Eric Coulston,<br /> <?php echo $today; ?></font> </div> <div id="blogmiddle"> <strong>Title:</strong> <input type="text" name="title"> <p><strong>Main Content:</strong><br /> <textarea style="height: 330px; width: 520px;" name="maincontent"></textarea></p> <input type="submit" name="check" value=" Check... " /> </div> <div id="blogright"> <strong>Side Content:</strong><br /> <textarea style="height: 370px; width: 260px;" name="sidecontent"></textarea> </div> </form> <?php } ?> <div id="footerline"> </div> </div> <!-- end body code --> <div id="footer"> Copyright © 2012 BubblyBounce.com, a division of CaresAbout, LLC. All rights reserved. </div> </div> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/276183-displaying-content-passed-from-a-variable/ Share on other sites More sharing options...
elmas156 Posted March 26, 2013 Author Share Posted March 26, 2013 Sorry, this was not supposed to be a duplicate post... Quote Link to comment https://forums.phpfreaks.com/topic/276183-displaying-content-passed-from-a-variable/#findComment-1421187 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.