farban Posted May 29, 2008 Share Posted May 29, 2008 When i add a post in my content managment system or update the post i need it so that it reads it as text and NOT code i need it so that when i add a article it will add it as text and not code and same for the update function i think it invovles using the mysql escape string here is each page for you ...im just not sure where to add the code on each of these pages to make it so that it will read it as text and not code To add the post <form action="" method="post"> <table class="tab2"> <tr> <td class="tab2a">Title</td> <td><input name="title" type="text"/></td> </tr> <tr> <td class="tab2a">Content</td> <td><textarea name="messege" cols="50" rows="10"></textarea></td> </tr> <tr> <td class="tab2a"> </td> <td> </td> </tr> <tr> <td class="tab2a"><input name="save" type="submit" value="Save Article"/></td> </tr> </table> </form> <?php if(isset($_POST['save'])) { $title = $_POST['title']; $messege = $_POST['messege']; if(!get_magic_quotes_gpc()) { $title = addslashes($title); $messege = addslashes($messege); } include 'library/config.php'; include 'library/opendb.php'; $query = " INSERT INTO pages (title, messege) ". " VALUES ('$title', '$messege')"; mysql_query($query) or die('Error ,query failed'); include 'library/closedb.php'; echo "Article '$title' added<br>"; } ?> <a class="menudiv" href="template.php?page=adminpanel">Click here to go back</a> To update the post <html> <head> <title>Edit An Article</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <style type="text/css"> <!-- .box { font-family: Arial, Helvetica, sans-serif; font-size: 12px; border: 1px solid white; background-color:#3a3839; color:white; } body { background-color:#3a3839; } a:link { color:white; text-decoration: none; } a:visited { color: white; text-decoration: none; } a:hover { color: blue; text-decoration: none; } a:active {color: white; text-decoration: none; } --> </style> </head> <body> <?php include 'library/config.php'; include 'library/opendb.php'; if(isset($_GET['page_id'])) { $query = "SELECT page_id, title, messege ". "FROM pages ". "WHERE page_id = '{$_GET['page_id']}'"; $result = mysql_query($query) or die('Error : ' . mysql_error()); list($page_id, $title, $messege) = mysql_fetch_array($result, MYSQL_NUM); $messege = mysql_real_escape_string($messege); } else if(isset($_POST['save'])) { $page_id = mysql_real_escape_string($_POST['page_id']); $title = mysql_real_escape_string($_POST['title']); $messege = mysql_real_escape_string($_POST['messege']); // if(!get_magic_quotes_gpc()) // { // $title = addslashes($title); // $messege = addslashes($messege); // } // update the article in the database } include 'library/closedb.php'; ?> <form method="post" action="updatepost.php"> <input type="hidden" name="page_id" value="<?=$page_id;?>"> <table width="700" border="0" cellpadding="2" cellspacing="1" class="box"> <tr> <td width="100">Title</td> <td><input name="title" type="text" class="box" id="title" value="<?=$title;?>"></td> </tr> <tr> <td width="100">Content</td> <td><textarea name="messege" cols="50" rows="10" class="box" id="messege"><?=$messege;?></textarea></td> </tr> <tr> <td width="100"> </td> <td> </td> </tr> <tr> <td colspan="2" align="center"><input name="update" type="submit" class="box" id="save" value="Update Article"></td> </tr> </table> <p align="center"><a href="template.php?page=adminpanel">Click here to go back to the admin panel</a></p> </form> </body> </html> after update <style type="text/css"> <!-- .box { font-family: Arial, Helvetica, sans-serif; font-size: 12px; border: 1px solid white; background-color:#3a3839; color:white; } body { background-color:#3a3839; font-family: Arial, Helvetica, sans-serif; font-size: 12px; background-color:#3a3839; color:white; } a:link { color:white; text-decoration: none; } a:visited { color: white; text-decoration: none; } a:hover { color: blue; text-decoration: none; } a:active {color: white; text-decoration: none; } --> </style> <?php include 'library/config.php'; include 'library/opendb.php'; $submit= mysql_real_escape_string($_POST['submit']); $page_id= mysql_real_escape_string($_POST['page_id']); //$date=$_GET['date']; $title= mysql_real_escape_string($_POST['title']); $messege= mysql_real_escape_string($_POST['messege']); //$menu_id = mysql_insert_id(); mysql_query("UPDATE pages SET title = '$title', messege ='$messege' WHERE page_id = '$page_id'") or die ("Couldn't execute query."); echo "Thank's for updating the post entitled <strong>$title</strong> in the database"; include 'library/closedb.php'; echo '<br><br><br><a href="template.php?page=adminpanel">Click here to go back to the admin panel</a>'; ?> and then the page to view the post on <?php include 'library/config.php'; include 'library/opendb.php'; // if no id is specified, list the available articles if(!isset($_GET['page_id'])) { $self = $_SERVER['PHP_SELF']; $query = "SELECT page_id, title FROM pages ORDER BY page_id"; $result = mysql_query($query) or die('Error : ' . mysql_error()); // create the article list $messege = '<ol>'; while($row = mysql_fetch_array($result, MYSQL_NUM)) { list($page_id, $title) = $row; $messege .= "<li class='doc'><a href='$self?page=storys&page_id=$page_id'>$title</a></li>\r\n"; } $messege .= '</ol>'; $title = 'Available Storys'; } else { // get the article info from database $query = "SELECT title, messege FROM pages WHERE page_id=".$_GET['page_id']; $result = mysql_query($query) or die('Error : ' . mysql_error()); $row = mysql_fetch_array($result, MYSQL_ASSOC); $title = $row['title']; $messege = "<textarea READONLY name='post$_GET[page_id]' cols='60' rows='30'>".$row['messege']."</textarea>"; } include 'library/closedb.php'; ?> <div class="admintitle"> <p>Story Page</p> </div> <div id="contentbox"> <p class="contenttext">Here is some of the fan fictions created by members of the clan and the leader of the clan himself. The fan fictions range from realistic to wild and wacky and I am sure there will be one to suit your tastes. You may also want to look at them for inspirations of your own fan fiction story. Check on the page regularly as more fan fictions will be added over time when the author can be bothered to complete them haha.</p> </div> <table class="tab"> <tr> <td class="tab"> <h1><?php echo $title; ?></h1> <?php echo $messege; // when displaying an article show a link // to see the article list if(isset($_GET['page_id'])) { ?> <p> </p> <p align="center"><a href="template.php?page=storys">Article List</a></p> <?php } ?> </td> </tr> </table> The problem is that..it shows up weird //r//n code in the textarea when viewing the story...also if i add " in the title when adding the story i cant deleate the story in the admin panel....also when i click on edit the double quotes and the text inside it dosent show up which means that it must be reading it as code. please help me im sure i provided it all here Link to comment https://forums.phpfreaks.com/topic/107817-really-needs-some-help-on-this-big-problem-of-mine/ Share on other sites More sharing options...
farban Posted May 29, 2008 Author Share Posted May 29, 2008 please any help ? i just need it so that when i add text into the feilds in the form such as double quotues and brackets it wont read it as code and will instead read it as just plain text here is my add page <form action="" method="post"> <table class="tab2"> <tr> <td class="tab2a">Title</td> <td><input name="ptitle" type="text"/></td> </tr> <tr> <td class="tab2a">News post</td> <td><textarea name="postmsg" cols="50" rows="10"></textarea></td> </tr> <tr> <td class="tab2a"> </td> <td> </td> </tr> <tr> <td class="tab2a"><input name="save" type="submit" value="Save Post"/></td> </tr> </table> </form> <?php if(isset($_POST['save'])) { $ptitle = $_POST['ptitle']; $postmsg = $_POST['postmsg']; if(!get_magic_quotes_gpc()) { $ptitle = addslashes($ptitle); $postmsg = addslashes($postmsg); } include 'library/config.php'; include 'library/opendb.php'; $query = " INSERT INTO posts (ptitle, postmsg) ". " VALUES ('$ptitle', '$postmsg')"; mysql_query($query) or die('Error ,query failed'); include 'library/closedb.php'; echo "Post '$ptitle' added<br>"; } ?> <a class="menudiv" href="template.php?page=adminpanelposts">Click here to go back</a> Link to comment https://forums.phpfreaks.com/topic/107817-really-needs-some-help-on-this-big-problem-of-mine/#findComment-552794 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.