vapour_ Posted June 7, 2008 Share Posted June 7, 2008 Hey, I have been working on a news posting system for my website, and everything was fine until i created an edit application. The system runs off a database. I have the editing page set up like this: top of page: <?php include("db_connect.php"); $title = $_POST['select']; $query = "SELECT * FROM newsPosts WHERE title = '".$title."';"; $result = mysql_query($query) or die ( mysql_error() ); ?> And this is the form: <?php while ($row = mysql_fetch_assoc($result)){?> <form action="news_edit_success.php" method="post" name="newsEdit"> <label> Title:<br> <input name="title" type="text" value="<?php echo $row["title"]; ?>" size="40"> <input type="hidden" name="titlehidden" value="<?php echo $row["title"]; ?>"> <br> <br> Message:<br> <textarea name="message" cols="45" rows="5" id="textfield"><?php echo $row["message"]; ?></textarea> <input type="hidden" name="messagehidden" value="<?php echo $row["message"]; ?>" > </label> <label> <br> <br> Posted by:<br> </label> <input name="author" type="text" value='<?php echo $row["author"]; ?>' size="30" > <br> <br> <br> <label> <input type="submit" name="submit" value="Update"> </label> <label> <input type="reset" value="Reset"> </label> <br> </form> <?php } ?> So that when the form goes to the next page i can update the title and the message with a SQL query like this: <?php include("db_connect.php"); $original_title = $_POST['titlehidden']; $original_message = $_POST['messagehidden']; $title = $_POST['title']; $message = $_POST['message']; $author = $_POST['author']; $query = "UPDATE newsPosts SET title = '".$title."' WHERE title = '".$original_title."' ;"; $query2 = "UPDATE newsPosts SET message = '".$message."' WHERE message = '".$original_message."';"; $result = mysql_query($query) or die ( mysql_error() ); $result2 = mysql_query($query2) or die ( mysql_error() ); ?> THE PROBLEM IS: When i started to add DIV, BR, STRONG, P tags etc... to the message the hidden fields just spat it out into the html code instead of keeping it hidden for use on the next page. I dont know whats up with it, and i cant figure it out as i am quite new to PHP and MySQL. If i have made a stupid mistake please forgive. Any help would be appreciated. Thanks. Link to comment https://forums.phpfreaks.com/topic/109084-solved-phpmysql-news-edit-application/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.