<html>
<head>
<title>Update a Record in MySQL Database</title>
</head>
<body>
<?php
if(isset($_POST['update'])) {
mysql_connect("localhost", "root" ,"");
mysql_select_db("project");
$conn = mysql_connect("localhost", "root" ,"");
if(! $conn ) {
die('Could not connect: ' . mysql_error());
}
session_start();
$emp_id = $_POST['emp_id'];
$Newname = $_POST['Newname'];
$tempo =$_SESSION['Username'];
echo $tempo;
$sql = "UPDATE user ". "SET Name = $Newname ".
"WHERE id = 6" ;
mysql_select_db('test_db');
$retval = mysql_query( $sql, $conn );
if(! $retval ) {
die('Could not update data: ' . mysql_error());
}
echo "Updated data successfully\n";
mysql_close($conn);
}else {
?>
<form method = "post" action = "edit.php">
<table width = "400" border =" 0" cellspacing = "1"
cellpadding = "2">
<tr>
<td width = "100">Employee ID</td>
<td><input name = "emp_id" type = "text"
></td>
</tr>
<tr>
<td width = "100">Employee Salary</td>
<td><input name = "Newname" type = "text"
></td>
</tr>
<tr>
<td width = "100"> </td>
<td> </td>
</tr>
<tr>
<td width = "100"> </td>
<td>
<input name = "update" type = "submit"
value = "Update">
</td>
</tr>
</table>
</form>
<?php
}
?>
</body>
</html>