I have a script whereby i can edit the content of a database thru clicking on a link which carries a ‘ID’ over to another page. The code in this post is the code for editing for the content. The script connects sucsessfully to the database and dispalys the current database content within its textboxes, the user can type in their new content over the text and click submit to update the database. However its not working properly. When the user clicks sumit nothing happens and the database does not get updated.
[code=php]<?
if(isset($_GET[‘id’]))
{
$query = “SELECT * FROM mynews WHERE id = ‘{$_GET[‘id’]}'”;
if (!isset($_POST[“submit”]))
{
$id = $_GET[“id”]; .
$sql = “SELECT * FROM mynews WHERE id=$id”;
$result = mysql_query($sql);
$myrow = mysql_fetch_array($result);
if ($_POST[“$submit”])
{
$title = $_POST[‘title’];
$message = $_POST[‘message’];
$user = $_POST[‘user’];
$email = $_POST[’email’];
$sql = “UPDATE mynews SET title=’$title’, message=’$message’, user=’$user’, email=’$email’ WHERE id=$id”;
$result = mysql_query($sql); //run this query
echo “Information updated. <a href=test2.php>Return</a>”;
}
?>
<form action=”editcontent.php” method=”post”>
<INPUT TYPE=”TEXT” NAME=”title” VALUE=”<?php echo $myrow[“title”] ?>” SIZE=30>
//more forms down here….
<input type=”submit” name=”submit” value=”submit”>
</form>
<?
}
}
?>
Any ideas where i might have gone wrong?