<?php
session_start();
include_once("db_connect.php");
if(isset($_POST['update']))
{
$ret_id=$_POST['ret_id'];
$ret_name=$_POST['ret_name'];
$ret_street=$_POST['ret_street'];
$ret_city=$_POST['ret_city'];
$ret_phone=$_POST['ret_phone'];
$ret_fax=$_POST['ret_fax'];
$ret_user_fname=$_POST['ret_user_fname'];
$ret_user_lname=$_POST['ret_user_lname'];
$ret_email=$_POST['ret_email'];
// checking empty field
if(empty($ret_name) || empty($ret_street) || empty($ret_city) || empty($ret_phone) || empty($ret_fax) || empty($ret_user_fname) || empty($ret_user_lname) || empty ($ret_email))
{
if(empty($ret_name))
{
echo "<font color='red'>Retailer Name field is empty.</font><br/>";
}
if(empty($ret_street))
{
echo "<font color='red'> Street field is empty.</font><br/>";
}
if(empty($ret_city))
{
echo "<font color='red'>City field is empty.</font><br/>";
}
if(empty($ret_phone))
{
echo "<font color='red'>Phone field is empty.</font><br/>";
}
if(empty($ret_fax))
{
echo "<font color='red'>Fax field is empty.</font><br/>";
}
if(empty($ret_user_fname))
{
echo "<font color='red'>First Name field is empty.</font><br/>";
}
if(empty($ret_user_lname))
{
echo "<font color='red'>Last Name field is empty.</font><br/>";
}
if(empty($ret_email))
{
echo "<font color='red'>Email field is empty.</font><br/>";
}
}
else
{
//updating the table
$result=mysql_query("UPDATE tblretailer SET ret_name='".$ret_name."', ret_street='".$ret_street."', ret_city='".$ret_city."', ret_phone='".$ert_phone."', ret_fax='".$ret_fax."', ret_user_fname='".$ret_user_fname."', ret_user_lname='".$ret_user_lname."', ret_email='".$ret_email."' WHERE ret_id='".$ret_id."';");
//redirectig to the display page. In our case, it is index.php
header("Location: del_updret.php");
}
}
?>
<?php
$ret_id = $_GET['ret_id'];
$result=mysql_query("SELECT ret_name, ret_street, ret_city, ret_phone, ret_fax, ret_user_fname, ret_user_lname, ret_email FROM tblretailer where ret_id = ".$ret_id."") or die(mysql_error());
?>
<html>
<title>Edit Product</title>
<body background="Images/contentbg.jpg">
<a href="del_updret.php"><img src="Images/back button.png" width="100" /></a>
<br/><br/>
<form name="edit" method="post" action="updretailer.php">
<table align="center" border="0">
<?php
while($res=mysql_fetch_array($result))
{
$ret_name=$res['ret_name'];
$ret_street=$res['ret_street'];
$ret_city=$res['ret_city'];
$ret_phone=$res['ret_phone'];
$ret_fax=$res['ret_fax'];
$ret_user_fname=$res['ret_user_fname'];
$ret_user_lname=$res['ret_user_lname'];
$ret_email=$res['ret_email'];
?>
<tr>
<td>Retailer Name</td>
<td>
<input type="text" name="ret_name" value = "<?php echo $ret_name;?>"> </td>
</tr>
<tr>
<td>Street</td>
<td>
<input type="text" name="ret_street" value = "<?php echo $ret_street;?>"> </td>
</tr>
<tr>
<td>City</td>
<td>
<input type="text" name="ret_city" value = "<?php echo $ret_city;?>"> </td>
</tr>
<tr>
<td>Phone</td>
<td>
<input type="text" name="ret_phone" value = "<?php echo $ret_phone;?>"> </td>
</tr>
<tr>
<td>Fax</td>
<td>
<input type="text" name="ret_fax" value = "<?php echo $ret_fax;?>"> </td>
</tr>
<tr>
<td>First Name</td>
<td>
<input type="text" name="ret_user_fname" value = "<?php echo $ret_user_fname;?>"> </td>
</tr>
<tr>
<td>Last Name</td>
<td>
<input type="text" name="ret_user_lname" value = "<?php echo $ret_user_lname;?>"> </td>
</tr>
<tr>
<td>Email</td>
<td>
<input type="text" name="ret_email" value = "<?php echo $ret_email;?>"> </td>
</tr>
<?php } ?>
<tr>
<td><input type="submit" name="update" value="Update"></td>
</tr>
</table>
</form>
</body>
</html>
the retailer table (tblretailer) is not being updated after the record displayed are altered
no error messages are generated