<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<TITLE>Update a Record</TITLE>
</HEAD>
<BODY>

<?
/***************************************************************************
 *			do_updaterec1.php	                           *
 *                       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~	                   *
 *   File Info:		  Update Contacts                                  *
 *   Copyright:       Copyright 2003 http://www.128concepts.com            *
 *						                           *
 ***************************************************************************/
include("./config.php");
include("./header.inc");
?>
<?
$table = "contacts";
  if ($_SERVER['REQUEST_METHOD'] == "POST") 
  {
        # escape data and set variables
        $cid = addslashes($_POST["cid"]);
        $ctitle = addslashes($_POST["ctitle"]);
        $cfirst = addslashes($_POST["cfirst"]);
        $csurname = addslashes($_POST["csurname"]);
        $cadd1 = addslashes($_POST["cadd1"]);
        $cadd2 = addslashes($_POST["cadd2"]);
        $ccity = addslashes($_POST["ccity"]);
        $ccounty = addslashes($_POST["ccounty"]);
        $ccode = addslashes($_POST["ccode"]);
        $cphone = addslashes($_POST["cphone"]);
        $cfax = addslashes($_POST["cfax"]);
        $cemail = addslashes($_POST["cemail"]);
}

$conn = @mysql_connect($server,$user,$password)
	or die("Unable to connect to SQL database...");
$rs = @mysql_select_db($database,$conn) 
	or die("Unable to select the database...Please press 'Create Database' to create new database.");
echo("<br><img src=images/line.gif border=0 width=100% height=1><font face=verdana size=2>Updating contacts record with Contact ID = ");
echo($cid);
echo("</font><br>");
$done = "FALSE";
$sql = " SELECT cid,ctitle,cfirst,csurname,cadd1,cadd2,ccity,ccounty,ccode,cphone,cfax,cemail from $table where cid = $cid";
$rs = @mysql_query($sql,$conn)
	or die("Could not execute SQL query!!! Possibly SQL query already been executed.");
while($row=mysql_fetch_array($rs))
{
     
       echo("<font face=verdana size=2>Contact ID: </font>".$row["cid"]); 
       echo(" <font face=verdana size=2>Title: </font>".$row["ctitle"]);
       echo(" <font face=verdana size=2>First Name: </font>".$row["cfirst"]);
       echo(" <font face=verdana size=2>Surname:  </font>".$row["csurname"]."<br>");
       echo("<font face=verdana size=2>Address #1:</font> ".$row["cadd1"]."<br>");
       echo("<font face=verdana size=2>Address #2:</font> ".$row["cadd2"]."<br>");
       echo("<font face=verdana size=2>City: </font>".$row["ccity"]."<br>");
       echo("<font face=verdana size=2>County: </font>".$row["ccounty"]."<br>");
       echo("<font face=verdana size=2>Post Code: </font>".$row["ccode"]."<br>");
       echo("<font face=verdana size=2>Phone: </font>".$row["cphone"]."<br>");
       echo("<font face=verdana size=2>Fax: </font>".$row["cfax"]."<br>");
       echo("<font face=verdana size=2>Email: </font>".$row["cemail"]."<br>");
       echo("<font face=verdana size=2>Press the 'View Records' menu link to view all contacts records.</font><img src=images/line.gif border=0 width=100% height=1>");
       $done = "OK";
       $cid=$row["cid"];
       $ctitle=$row["ctitle"];
       $cfirst=$row["cfirst"];
       $csurname=$row["csurname"];
       $cadd1 = $row["cadd1"];
       $cadd2=$row["cadd2"];
       $ccity = $row["ccity"];
       $ccounty=$row["ccounty"];
       $ccode=$row["ccode"];
       $cphone=$row["cphone"];
       $cfax = $row["cfax"];
      $cemail=$row["cemail"];
}
if ($done=="FALSE")
{
echo("<font face=verdana size=2>Opps...its seems cannot update contact record with CONTACT ID = ");
	echo($cid);
	echo "</font><img src=images/line.gif border=0 width=100% height=1><br><br><br><br><br>";
	include_once("./your-footer.inc");
	exit();
}
$form = "<form action=do_updates1.php";
$form.=" method=\"POST\">";
$form.="<input type=\"hidden\" name=\"cid\" value=\"$cid\" size=\"10\">";
$form.="Title:<br> ";
$form.="<input type = \"text\" name=\"ctitle\"";
$form.=" value=\"$ctitle\" size = \"10\"><br>First Name:<br> ";
$form.="<input type=\"text\" name=\"cfirst\"";
$form.=" value=\"$cfirst\" size=\"25\"><br>Surname:<br>";
$form.="<input type=\"text\" name=\"csurname\"";
$form.= "value=\"$csurname\" size=\"30\"><br>Address #1:<br>";
$form.="<input type=\"text\" name=\"cadd1\"";
$form.="value=\"$cadd1\" size=\"100\"><br>Address #2:<br>";
$form.="<input type=\"text\" name=\"cadd2\"";
$form.="value=\"$cadd2\" size=\"100\"><br>City:<br>";
$form.="<input type=\"text\" name=\"ccity\"";
$form.="value=\"$ccity\" size=\"50\"><br>County:<br>";
$form.="<input type=\"text\" name=\"ccounty\"";
$form.="value=\"$ccounty\" size=\"50\"><br>Post Code:<br>";
$form.="<input type=\"text\" name=\"ccode\"";
$form.="value=\"$ccode\" size=\"15\"><br>Phone:<br>";
$form.="<input type=\"text\" name=\"cphone\"";
$form.="value=\"$cphone\" size=\"25\"><br>Fax:<br>";
$form.="<input type=\"text\" name=\"cfax\"";
$form.="value=\"$cfax\" size=\"25\"><br>Email:<br>";
$form.="<input type=\"text\" name=\"cemail\"";
$form.="value=\"$cemail\" size=\"25\"><br><br>";
$form.="<input type=\"submit\" value=\"Update Record\">";
$form.="</form>";
echo($form);
?>
<br><font face=verdana size=2 color=navy>To update the contact record, update the fields and then press 'Update Record' to update the contact record '<?php echo "$pid"?>'</font><br><br>
<center>
<table width="500" border=1><tr align="justify" class="subtitle"><td>
  <p align="center">
  <img border="0" src="images/database.GIF" width="24" height="24"><font face=Verdana size=1><a href="./create_db.php">Create database</a>&nbsp;
  <img border="0" src="images/database.GIF" width="24" height="24"></font><a href="./delete_db.php"><font face=Verdana size=1>Delete database</font></a><font face="Verdana" size="1">&nbsp;
  <img border="0" src="images/Records.GIF" width="24" height="24"><a href="./create_menu.php">Create table</a>&nbsp;&nbsp;&nbsp;&nbsp;
  <img border="0" src="images/Records.GIF" width="24" height="24">&nbsp;
  </font> <a href="./add_menu.php"><font face=Verdana size=1>Add Record </font></a>  
  </p>
  <p align="center">&nbsp;<font face="Verdana" size="1"><img border="0" src="images/Records.GIF" width="24" height="24"></font><a href="./view_menu.php"><font face=verdana size=1>View Records</font></a>&nbsp;
  <font face="Verdana" size="1">&nbsp;&nbsp;&nbsp;
  <img border="0" src="images/Records.GIF" width="24" height="24"></font><a href="./del_menu.php"><font face=verdana size=1>Delete Record</font></a>
  <font face="Verdana" size="1">&nbsp;&nbsp;&nbsp;
  <img border="0" src="images/Records.GIF" width="24" height="24"></font> <a href="./upd_menu.php"><font face=verdana size=1>Update Record</font></a>&nbsp;
  <img border="0" src="images/home-to.GIF" width="24" height="24"><font face=verdana size=1>&nbsp; <a href="./index.php">Home</a></font>  </a></td></tr></table><br></center>
<?php include("./your-footer.inc");?>
</BODY>
</HTML>
