Hey guys, i'm having a bit of trouble with this news updating system...I have a main manage page which lists all of the news entries and beside each one there is an "edit entry" link which brings it to a page where the user is able to update the information and then submit it.
Here is the code for the page that "Edit Entry" is linked too.
PHP Code:
<?
require_once('../../mysql_connect.php'); $query = "SELECT name, date, message FROM news WHERE id=$id"; $result = @mysql_query($query); $row = mysql_fetch_array ($result, MYSQL_NUM); echo '<div id="wrapper" align="center"> <span class="title"><b>Edit News Entry</b></span><br /><br /> <form method="post" action="editnews_handler.php">
<span>Date:</span><br />
<INPUT TYPE="TEXT" NAME="date" VALUE="' . $row[1] . '" size=20><br /><br>
<span>Message:</span><br /> <textarea name="message" cols="60" rows="5" wrap="physical">' . $row[2] . '</textarea> <br /> <span style="font-size:10px">**Try to keep image\'s width smaller than 400 pixles!</span> <br /> <br />
<span>Name:</span><br />
<div class="submit"><INPUT TYPE="TEXT" NAME="name" VALUE="' . $row[0] . '" size=40 ></div><br /><br />
<INPUT TYPE="submit" name="submit" value="submit news">
</form> </div>';
mysql_close(); ?>
This page displays the information in the form perfectly. The problem is it's handler. Which is this:
PHP Code:
<? if($_POST['submit']) { require_once('../../mysql_connect.php'); $query = "UPDATE news SET message='$a', name='$b', date='$c' WHERE id=$id"; $result = mysql_query($query);} ?> Query Updated. <br /> <a href="/manage" target="_self">Go Back</a>
Now I know i have not named these variables yet, but i'm not really sure how, or even if this method is correct.
Any help is very appreciative. Thanks!
Last edited by iisthesloth; 10-27-2005 at 10:07 PM..
|