dare87 Posted August 4, 2007 Share Posted August 4, 2007 I am trying to write a page that will allow others to edit webpages on my website. I have written the code so that you can "Compose" news once it has been composed it goes to the "Approve" section here you either approve or delete the composed news. When the file has been composed and then approved I want to be able to edit the news. The whole this is setup in a database. I have got everything working except when I submit the Changes... it just goes back to my review page and does not edit the news.. <?php require_once('../../datemysql_connect.php'); // Get the article id from the URL. $userrating = $_GET['userrating']; // Start and run the query. $query = "SELECT title AS title, rating AS rating, supplies AS supplies, date AS article, cost AS cost FROM datedb WHERE user_rating=$userrating"; $results = @mysql_query($query); if ($results) { $row = mysql_fetch_array($results, MYSQL_ASSOC); // Save the results into variables. $title = $row['title']; $rating = $row['rating']; $supplies = $row['supplies']; $article = $row['article']; $cost = $row['cost']; } else echo 'An error occured.'; ?> <div id="content"> <div class="innerContent"> <form name="EditDate" action="date_edit.php" method="post"> <table align="center" width="100%" border="0" cellpadding="1" cellspacing="0"> <tr> <td class="title" colspan="2">Edit Date</td> </tr> <tr> <td>Title:</td> <td><input type="text" class="required" name="title" id="focus" size="40" value="<?php echo $title; ?>" maxlength="200"></td> </tr> <tr> <td>Rating:</td> <td><input type="text" class="required" name="rating" size="1" value="<?php echo $rating; ?>" maxlength="1"></td> </tr> <tr> <td>Supplies:</td> <td><input type="text" class="required" name="supplies" size="40" value="<?php echo $supplies; ?>"></td> </tr> <tr> <td>Article:</td> <td><textarea class="required" name="article" rows="30" cols="70"><?php echo $article; ?></textarea></td> </tr> <tr> <td>Cost:</td> <td><input type="text" class="required" name="cost" size="40" value="<?php echo $cost; ?>"></td> </tr> <tr> <td> </td> <td><input type="submit" class="button" name="submit" value="Submit"><input type="hidden" name="userrating" value="<?php echo $userrating; ?>"></td> </tr> <tr> <td> </td> <td class="smallText">* Highlighted forms designate required fields.</td> </tr> </table> </form> <?php if (isset($_POST['submit'])) // The form has been submitted. { // Initialize an error array to contain any error messages. $errors = array(); // Check for a title. if (!empty($_REQUEST['title'])) $title = $_REQUEST['title']; else $errors[] = 'Please enter a title.'; // Check for an rating. if (!empty($_REQUEST['rating'])) $rating = $_REQUEST['rating']; else $errors[] = 'Please enter rating.'; // Check for an supplies. if (!empty($_REQUEST['supplies'])) $supplies = $_REQUEST['supplies']; else $errors[] = 'Please enter an supplies.'; // Check for an article. if (!empty($_REQUEST['article'])) $article = $_REQUEST['article']; else $errors[] = 'Please enter an article.'; // Check for an cost. if (!empty($_REQUEST['cost'])) $cost = $_REQUEST['cost']; else $errors[] = 'Please enter cost.'; $userrating = $_REQUEST['userrating']; // Submit the article. if (empty($errors)) { // Connect to the database. require_once('../../datemysql_connect.php'); $query = "UPDATE datedb SET title='$title', rating AS $rating, supplies AS '$supplies', article='$article' cost AS '$cost', WHERE user_rating=$userrating"; $results = @mysql_query($query); $url = 'date_review.php'; header("Location: $url"); } else foreach ($errors as $msg) echo " - $msg<br/>\n"; } ?> Any help would be great and if you need more info just let me know Quote Link to comment Share on other sites More sharing options...
dare87 Posted August 4, 2007 Author Share Posted August 4, 2007 well i am just dumb!!! I solved my own problem after reading it again 20 times $query = "UPDATE datedb SET title='$title', rating=$rating, supplies='$supplies', date='$article', cost='$cost' WHERE user_rating=$userrating"; Quote Link to comment 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.