pneudralics Posted November 16, 2008 Share Posted November 16, 2008 When I just use regular text in my form it saves it but when I try to enter the below it doesn't save it. Can't figure why..If I manually enter it in the database it'll save it. blahblabh<br>yayaya<br>testing one two<br><img alt="" src="http://l" align="none"><img alt="mustang" src="http://localhost/gallery/mustang1.jpg" align="none"><br> php page <?php //This is the page for updating the policy section session_start(); if(!isset($_SESSION['username'])){ require ("error.php"); } else { include ('header2.php'); ?> <table width="800" align="center"> <tr> <td align="center"> This section updates the policy section. Clicking on the save button will override the current policy information. </td> </tr> </table> <br /> <table width="800" align="center"> <tr> <td align="center"> <?php //Update policy if (isset ($_POST['submit'])) { $policy = ($_POST['policy']); if ( !empty ($policy) ) { //Update... $updatepolicy = "UPDATE policy SET policy=\"$policy\""; $updatepolicyresult = mysql_query ($updatepolicy); echo '<font color="red">Policy section has been updated.</font><br /><br />'; } else { echo '<font color="red">Policy section is empty.</font><br /><br />'; } } ?> [<a href="../policy.php" target="_blank">View Policy Section</a>] <br /> <br /> <b>Update Policy Section Below</b> <br /> <form method="post" action="policy.php"> <textarea name="policy" cols="40" rows="20"> <?php //Retrieve policy info $policyselect = "SELECT * FROM policy"; if ($policyresult = mysql_query ($policyselect)) { while ($row = mysql_fetch_array ($policyresult)) { $policy = $row['policy']; } } echo "$policy"; ?> </textarea> <br /> <br /> <input type="submit" name="submit" value="Save" /> </form> </td> </tr> </table> <?php }//End session else ?> SS Link to comment https://forums.phpfreaks.com/topic/132929-solved-cant-get-mysql-to-save-tags-and-other-html/ Share on other sites More sharing options...
pneudralics Posted November 16, 2008 Author Share Posted November 16, 2008 Got it. I had to use htmlspecialchars() to save it to mysql. I then decode it to display it. Link to comment https://forums.phpfreaks.com/topic/132929-solved-cant-get-mysql-to-save-tags-and-other-html/#findComment-691242 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.