<?php
/***************************************************************************
 *			upd_userphp                                        *
 *                     	          				           *
 *   File Info:		  Updating Users                                   *
 *   Copyright:       Copyright 2003 http://www.128concepts.com            *
 *						                           *
 ***************************************************************************/
include ("config.php");
include ("./your-header.inc");
include ("./tests.php");
$strvar = getenv("QUERY_STRING");
$pos = strpos($strvar,'=');
if ($pos>=0) 
	$username = substr($strvar,$pos+1);

 if ($_SERVER['REQUEST_METHOD'] == "POST") 
  {
        # escape data and set variables
        $username = addslashes($_POST["username"]);
}
$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><center><img src=images/line.gif border=0 width=500 height=1><br><font face=verdana size=2>Unable to find user details for '$username'<br>Maybe the user account does not exist or has been deleted!</font><br><img src=images/line.gif border=0 height=1 width=500></center><br><br>");
	include("./your-footer.inc");
	exit();
}
if (((session_is_registered("admin")) and ($_SESSION['admin'] != "admin")) or ((session_is_registered("admin")) and ($_SESSION['admin'] == "admin")))
{
	while($row = mysql_fetch_array($rs))
	{
	$username = $row["username"];
	$firstname = $row["firstname"];
	$lastname = $row["lastname"];
	$passwrd  = $row["passwrd"];
	$email     =  $row["email"];
	$hint       =  $row["hint"];
	}
	$form = "<center><img src=images/computer1.gif border=0><br><br><img src=images/line.gif width=500 height=1><br><font face = Verdana size = 2 color = darkred><br> Please update fields you wish to update for your user details</font>";
	$form.= "<table>";
	$form.= "<form action = upd_users.php method = post>";
	$form.="<INPUT type=\"hidden\" name =\"username\" value=$username>";
	$form.="<tr>";
	$form.= "<td valign=top><strong>First Name</strong></td>";
	$form.="<td valign=top>";
	$form.="<INPUT type=\"text\" name=\"firstname\" value = $firstname size=25 maxlength=25>";
	$form.="</td></tr>";
	$form.="<tr>";
	$form.="<tr>";
	$form.= "<td valign=top><strong>Last Name</strong></td>";
	$form.="<td valign=top>";
	$form.="<INPUT type=\"text\" name=\"lastname\" value = $lastname size=25 maxlength=25>";
	$form.="</td></tr>";
	$form.="<tr>";
	$form.="<tr>";
	$form.= "<td valign=top><strong>Password</strong></td>";
	$form.="<td valign=top>";
	$form.="<INPUT type=\"password\" name=\"passwrd\"  size=25 maxlength=25>";
	$form.="</td></tr>";
	$form.="<tr>";
	$form.="<tr>";
	$form.= "<td valign=top><strong>Email</strong></td>";
	$form.="<td valign=top>";
	$form.="<INPUT type=\"text\" name=\"email\" value = $email size=25 maxlength=45>";
	$form.="</td></tr>";
	$form.="<tr>";
	$form.="<tr>";
	$form.= "<td valign=top><strong>Hint</strong></td>";
	$form.="<td valign=top>";
	$form.="<INPUT type=\"text\" name=\"hint\" value = '$hint' size=25 maxlength=55>";
	$form.="</td></tr>";
	$form.="<td>";
	$form.="<input type=\"submit\" value=\"Update Details\">";
	$form.= "</form></td>";
	echo($form);
	 echo"<td>
	<form method=POST action=del_usera.php>
	<input type=hidden name=username value='$username'>
	<input type=submit name=submit value='Delete User'>
	</form></td></table><img src=images/line.gif border=0 width=500 height=1><br>";
	echo("<br><center><font face=verdana size=2>You must input original or updated password in password field...<br>If you leave the field blank the password will be set to blank!!!!<br>Do not use character ' in your updated fields</font></center>");
}
?>
<html>
<head>
<title>
Update User Details
</title>
</head>
<body>
<?php  
echo"<br><center>	
<table width=65% 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>
