<?php
/***************************************************************************
 *			upd_users.php                                      *
 *                     	          				           *
 *   File Info:		  Updating Users                                   *
 *   Copyright:       Copyright 2003 http://www.128concepts.com            *
 *						                           *
 ***************************************************************************/
include ("config.php");
include ("./your-header.inc");
include ("./tests.php");
 if ($_SERVER['REQUEST_METHOD'] == "POST") 
  {
        # escape data and set variables
        $username = addslashes($_POST["username"]);
        $firstname = addslashes($_POST["firstname"]);
        $lastname = addslashes($_POST["lastname"]);
        $passwrd=addslashes($_POST["passwrd"]);
        $email=addslashes($_POST["email"]);
        $hint=addslashes($_POST["hint"]);
}

if ($username != NULL and $firstname != NULL and $lastname != NULL and $passwrd != NULL and $email != NULL and $hint != NULL)
{

}
else
{
	echo("<br><br><br><center><img src=images/line.gif border=0 width=550 height=1><br><img src=images/bullets.gif border=0><font face=verdana size=2> Opps...unable to continue updating your user details, all data fields must have data!!!</font><br><img src=images/line.gif border=0 width=550 height=1></center>");
	include("./your-footer.inc");
	exit();
}
$table = "users";
$conn = @mysql_connect($server,$user,$password)
	or die("Unable to connect to SQL database...");
$pass = md5($passwrd);
$rs = @mysql_select_db($database,$conn) 
	or die("Unable to select the database 'mydata'...Please press 'Create Database' to create new database.");
$sql = "select * from $table where username = '$username'";
$rs = mysql_query($sql,$conn)
	or die("Could not execute SQL query!!! Possibly SQL query already been executed.");
$num = mysql_numrows($rs);
if ($num == 0)
{
	echo("<br><br><br><center><img src=images/line.gif border=0 width=550 height=1><br><img src=images/bullets.gif border=0><font face=verdana size=2> Unable to find user details for '$username'</font><br><img src=images/line.gif border=0 width=550 height=1><br></center>");
	include("./your-footer.inc");
	exit();
}
if (((session_is_registered("admin")) and ($_SESSION['admin'] != "admin")) or ((session_is_registered("admin")) and ($_SESSION['admin'] == "admin")))
{
	echo "<center><img src=images/computer1.gif border=0><font face=verdana size=2 color=darkred> Updating your user details</font></center><br><img src=images/line.gif border=0 width=100% height=1><br>";
	echo "<font face=verdana size=2>User Name : $username</font><br>";
	echo "<font face=verdana size=2>First Name : $firstname</font><br>";
	echo "<font face=verdana size=2>Last Name : $lastname</font><br>";
	echo "<font face=verdana size=2>Password  : ????????</font><br>";
	echo "<font face=verdana size=2>Email        : $email</font><br>";
	echo "<font face=verdana size=2>Hint          : $hint</font><br>";
	$passwrd = md5($passwrd);
echo("<br><font face=verdana size=2>Updating First Name</font><br>");
$sql="UPDATE $table set firstname=";
$sql.="'$firstname'";
$sql.=" where username = '$username'";
$sql_result = mysql_query($sql,$conn)
	or die("Couldn't update record.");
echo("<font face=verdana size=2>Updating Last Name</font><br>");
$sql="UPDATE $table set lastname=";
$sql.="'$lastname'";
$sql.=" where username = '$username'";
$sql_result = mysql_query($sql,$conn)
	or die("Couldn't update record.");
echo("<font face=verdana size=2>Updating Password</font><br>");
$sql="UPDATE $table set passwrd=";
$sql.="'$passwrd'";
$sql.=" where username = '$username'";
$sql_result = mysql_query($sql,$conn)
	or die("Couldn't update record.");
echo("<font face=verdana size=2>Updating Email</font><br>");
$sql="UPDATE $table set email=";
$sql.="'$email'";
$sql.=" where username = '$username'";
$sql_result = mysql_query($sql,$conn)
	or die("Couldn't update record.");
echo("<font face=verdana size=2>Updating Hint</font><br><img src=images/line.gif border=0 width=100% height=1>");
$sql="UPDATE $table set hint=";
$sql.="'$hint'";
$sql.=" where username = '$username'";
$sql_result = mysql_query($sql,$conn)
	or die("Couldn't update record.");
}
?>
<html>
<head>
<title>
Update User Details
</title>
</head>
<body>
<?php  
echo"<br><center>	
<table width=60% cellpadding=0 cellspacing=0 border=0 bgcolor=FFFFFF align = middle><tr><td valign=top>
<table width=100% cellpadding=1 cellspacing=3 border=0 align = middle>
<tr bgcolor=ffffff><td>
&nbsp;<font face=Verdana size=-1><b><a href=./shop_showall.php>Product List</a></b><img src = ./images/shop.gif><br><small>&nbsp;</small></font>
<td>&nbsp;<font face=Verdana size=-1><b><a href=./shop_delcart.php>Empty Cart</a></b><img src = ./images/trashicon.gif><br><small>&nbsp;</small></font></td>
<td>&nbsp;<font face=Verdana size=-1><b><a href=./shop_viewcart.php>View Cart</a></b><img src = ./images/shoppingcart.gif width=18 height = 18><br><small>&nbsp;</small></font></td>
</table></td></tr></table></center><br>";
echo "<center><img src=images/back-to.gif>Back to <a href=login.php><font face=verdana size=2>Adminstrator's Panel</font></a></center>";
include ("./your-footer.inc");
?>
</body>
</html>
