Hi Guys,
I am new to all this so please bear with me.


I have created a database to house all our passwords for our department and the database has 3 columns. "System" "Password" and "Description". I am trying to make a webpage to be able to edit any row of the database but am getting stuck at the end. The web page lists everything in my database under the "system" column with a edit button as a link. Then once the link is choosen it populates a form at the bottom with the information inside it. Once i change anything on the form and click the submit form it should "echo Thank you! Information updated." but doesnt it doesnt update the database it just returns me to edit.php and nothing has changed

My script is listed below any help on getting it to actually update the database would be great thanks

Stephanie

<body>

<?
mysql_connect("localhost","root","mypassword");

mysql_select_db("BACSPINS2");

if(!isset($cmd))
{

$result = mysql_query("select * from password order by id");

while($r=mysql_fetch_array($result))
{
$System=$r["System"];
$id=$r["id"];

echo "<a href='edit.php?cmd=edit&id=$id'>$System - Edit</a>";
echo "<br>";
}
}
?>
<?
if($_GET["cmd"]=="edit" || $_POST["cmd"]=="edit")
{
if (!isset($_POST["submit"]))
{
$id = $_GET["id"];
$sql = "SELECT * FROM password WHERE id=$id";
$result = mysql_query($sql);
$myrow = mysql_fetch_array($result);
?>

<form action="edit.php" method="post">
<input type=hidden name="id" value="<?php echo $myrow["id"] ?>">

System:<INPUT TYPE="TEXT" NAME="System" VALUE="<?php echo $myrow["System"] ?>" SIZE=100><br>
Password:<INPUT TYPE="TEXT" NAME="Password" VALUE="<?php echo $myrow["Password"] ?>" SIZE=97><br>
Description:<INPUT TYPE="TEXT" NAME="Description" VALUE="<?php echo $myrow["Description"] ?> SIZE=100><br>
<br>
<input type="hidden" name="cmd" value="edit">

<input type="submit" name="submit" value="submit">

</form>

<? } ?>
<?
if ($_POST["$submit"])
{
$System = $_POST["System"];
$Password = $_POST["Password"];
$Description = $_POST["Description"];

$sql = "UPDATE password SET System='$System' ,Password='$Password',Description='$Description' WHERE id=$id";
$result = mysql_query($sql);
echo "Thank you! Information updated.";
}
}
?>