I want to update data from form to database using PHP. But there too many issues come on my code just like "Could not update data: Unknown column 'Nabeel' in 'field list'".
Please check the code and give me solution.
Thanks, Nabeel.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.11.1.min.js"></script>
<script type="text/javascript">
function doSomething() {
alert('Are you sure you want to delete this file ??');
}
</script>
</head>
<body>
<h2>Update Data Using PHP</h2>
</div>
<?php
$con = mysql_connect("localhost", "root", "");
$db = mysql_select_db("firstphp", $con);
if (isset($_GET['submit'])) {
$id = $_GET['id'];
$username = $_GET['username'];
$passward = $_GET['passward'];
$name = $_GET['name'];
$query = mysql_query("update users set
username='$username', passward='$passward', name='$name' where id='$id'", $con);
}
$query = mysql_query("select * from users", $con);
while ($row = mysql_fetch_array($query))
{
echo "<b><a href='update.php?update={$row['id']}'>{$row['id']}</a></b>";
echo "<br />";
}
?>
</div><?php
if (isset($_GET['submit'])) {
$submit = $_GET['submit'];
$query1 = mysql_query("select * from users where id=$submit", $con);
while ($row1 = mysql_fetch_array($query1)) {
echo "<form method='get'>";
echo "<hr/>";
echo"<input class='input' type='hidden' name='id' value='{$row1["id"]}' />";
echo "<br />";
echo "<label>" . "Name:" . "</label>" . "<br />";
echo"<input class='input' type='text' name='username' value='{$row1["username"]}' />";
echo "<br />";
echo "<label>" . "Email:" . "</label>" . "<br />";
echo"<input class='input' type='text' name='passward' value='{$row1["passward"]}' />";
echo "<br />";
echo "<label>" . "Name:" . "</label>" . "<br />";
echo"<input class='input' type='text' name='name' value='{$row1["name"]}' />";
echo "<br />";
echo "<input class='submit' type='submit' name='submit' value='submit' />";
echo "</form>";
}
}
if (isset($_GET['submit'])) {
echo '<div class="form" id="form3"><br><br><br><br><br><br>
<Span>Data Updated Successfuly......!!</span></div>';
}
mysql_close($con);
?>
</bod
></body>
</html>