Here is my script, it is for a blocks system i have created for a CMS i'am writing, however, i'm really struggling with update/edit pages, i want a page where you can update a block in the database, i will add admin protection later, anyway, my problem is, i can't get the form to update the database, i have tried using variables instead of $name for form input e.g.
$fname = $_POST['name']
$fcontent = $_POST['content']
but this still makes no difference, the page just refreshes, but no update is made to the database. I have tried using other fields from the database like " WHERE name = 'name here' " but that didn't work either, so i don't think its anything to do with auto-increment. It just won't work, can you help me because i really need to work out how to do an update page.
<HTML>
<?php
if($submit){
include("config.php"); //include config file
$db = mysql_connect ($dbhost, $dbuser, $dbpass) or die ("cannot connect to database"); //create database connection variable, called 'db'
mysql_select_db($dbname,$db); //select the database, specify database name, then connect
$sql = "UPDATE blocks WHERE position = '3' SET name = '$name', content = '$content'";
mysql_query($sql);
echo "Information updated...";
} else {
?>
<form method="post" action="<? echo $PHP_SELF ?>">
Name:<input type="Text" name="name"><br>
Content:<input type="Text" name="content"><br>
Position:<input type="Text" name="position"><br>
<input type="Submit" name="submit" value="Update information"></form>
<?
}
?>
</HTML>