I am getting the data from db and updating it here and trying to sending back to db. The error is undefined variable row.I am accessing with index values instead of their names.
<!DOCTYPE HTML>
<?php
include_once('DBConnection.php');
if( isset($_GET['edit']) )
{
$id = $_GET['edit'];
$res= mysql_query("SELECT * FROM details WHERE id='$id'");
$row= mysql_fetch_array($res);
}
if( !empty($_POST['newName'])&& isset($_POST['newName'])&& !empty($_POST['email'])&& isset($_POST['email'])&&!empty($_POST['phonenumber'])&& isset($_POST['phonenumber']))
{
$newName = $_POST['newName'];
$EMail = $_POST['email'];
$PhoneNumber = $_POST['phonenumber'];
$id = $_POST['id'];
$sql = "UPDATE details SET name='$newName' email='$EMail' phonenumber='$PhoneNumber' WHERE id='$id'";
$res = mysql_query($sql)
or die("Could not update".mysql_error());
echo "<meta http-equiv='refresh' content='0;url=random.php'>";
}
?>
<form action="edit.php" method="POST">
PhoneNumber: <input type="text" name="phonenumber" value="<?php echo $row[3];?>"/><br />
EMail: <input type="text" name="email" value="<?php echo $row[2];?>"/><br />
Name: <input type="text" name="newName" value="<?php echo $row[1];?>"/><br />
SlNo<input type="hidden" name="SlNo" value="<?php echo $row[0];?>"/>
<input type="submit" value=" Update "/>
</form>