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

<?
/***************************************************************************
 *			do_deleterec4.php	                           *
 *                       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~	                   *
 *   File Info:		  Delete Users record                              *
 *   Copyright:       Copyright 2003 http://www.128concepts.com            *
 *						                           *
 ***************************************************************************/
include("./config.php");
include("./header.inc");
?>
<img src=images/line.gif border=0 width=100% height=1><br><br>
<center><img src=images/computer.gif border=0><font face=verdana size=3 color=darkred> Deleting records from USERS table</font></center><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>
<?
$table = "users";
  if ($_SERVER['REQUEST_METHOD'] == "POST") 
  {
        # escape data and set variables
        $username = addslashes($_POST["username"]);
}

$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 'mydata'...Please press 'Create Database' to create new database.");
echo("<br><font face=verdana size=2>Deleting user record with User Name = ");
echo($username);
echo("</font><br>");
$done = "FALSE";
$sql = "SELECT * from $table where username = '$username'";
echo("$sql <img src=images/line.gif border=0 width=100% height=1>");
$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("User Name: ".$row["username"]); 
       echo("<br> First Name: ".$row["firstname"]);
       echo("<br> Last Name: ".$row["lastname"]);
       echo("<br> Password: ".$row["passwrd"]);
       echo("<br> Email:  ".$row["email"]);
       echo("<br> Hint: ".$row["hint"]);
      echo("<br> Date Added: ".$row["date_added"]."<br>");
       echo("Press the 'View Records' menu link to view all users records.<hr>");
       $done = "OK";
}
if ($done=="FALSE")
{
	echo("<br><br><center><img src=images/bullets.gif border=0><font face=verdana size=2 color=red> Opps...its seems cannot delete user record with USER NAME = ");
	echo($username);
	echo "</font></center>";
}
$sql = "DELETE FROM $table WHERE username= '$username'";
?>
<?

if ($done == OK)
{
	if ($username == "admin")
	{

	echo("<br><br><center><img src=images/bullets.gif border=0><font face=verdana size=2 color=red> Opps...its seems you cannot delete administrator's user record!");
	echo "</font></center>";
	include("./your-footer.inc");
	exit();
	}
	$sql_result = @mysql_query($sql,$conn)
	or die("Couldn't delete record.");

if ($sql_result)
	echo("<br><br><center><img src=images/bullets.gif border=0><strong><font face=verdana size=2 color=darkgreen>Deleting of user record '$username' successful</font></center></strong>");
else
	echo("<br><br><center><img src=images/bullets.gif border=0><strong><font face=verdana size=2 color=black>Deleting of user record '$username' not successful</font></center></strong>");
}
?>
<?php include("./your-footer.inc");?>
</BODY>
</HTML>
