<?php
session_start();
session_register('staff');



include ("connect.php");

	$memLname = $_POST["memLname"];
	$memName = $_POST["memName"];
	$memPassword = $_POST["memPassword"];
	$memICDate = $_POST["memICDate"];
	$memICState = $_POST["memICState"];
	$memICNo = $_POST["memICNo"];
	$memBdate= $_POST["memBdate"];
	$memSex = $_POST["memSex"];
	$memRace = $_POST["memRace"];
	$memAddress = $_POST["memAddress"];
	$memPcode = $_POST["memPcode"];
	$memCity = $_POST["memCity"];
	$memState = $_POST["memState"];
	$memHnum1 = $_POST["memHnum1"];
	$memHnum2 = $_POST["memHnum2"];
	$memHpnum1 = $_POST["memHpnum1"];
	$memHpnum2 = $_POST["memHpnum2"];
	$memEmail = $_POST["memEmail"];
	
if($_POST["Approve"] == "Approve")
{
	if(($memLname == "")||($memName == "")||($memPassword == "")||($memICDate == "")||($memICState == "")||($memICNo == "")
	||($memBdate == "")||($memSex == "")||($memRace == "")||($memAddress == "")||($memPcode == "")||($memCity == "")||($memState == "")
	||($memHnum1 == "")||($memHnum2 == "")||($memHpnum1 == "")||($memHpnum2 == "")||($memEmail == ""))
	{
echo "<script>alert('Member Information Incomplete!')</script>";
echo "<script language='javascript'>window.location='memlist.php'</script>";
	}
	
else{
	$result = mysql_query("INSERT INTO membership(memberLname, memberName, memberPassword, memberICDate, memberICState, memberICNo, memberBdate, memberSex, memberRace, memberAddress, memberPcode, memberCity, memberState, memberHnum1, memberHnum2, memberHpnum1, memberHpnum2, memberEmail)
	VALUES
	('$memLname', '$memName', '$memPassword', '$memICDate', '$memICState', '$memICNo', '$memBdate', '$memSex', '$memRace', '$memAddress', '$memPcode', '$memCity', '$memState', '$memHnum1', '$memHnum2', '$memHpnum1', '$memHpnum2', '$memEmail')");
	

	$query1=mysql_query("delete from member where memLname='$memLname'");
	
	$db = mysql_close();
	echo "<script language='javascript'>alert('Approve success.')</script>";
	echo "<script language='javascript'>window.location='memlist.php'</script>";
	}
}

if($_SESSION['staff']!= null)
{
?>
<html>
<head>
<title>Daily Bookstore - Management System</title>
<!--include css file-->
<link href="bookstaff.css" rel="stylesheet" type="text/css"/>
</head>

<body>

<?php
include ("stafffunctionbar.php");
?>
</div>
</fieldset>
</td>
</tr>
</table>

</center>

<hr/>
<center>
<h2>Member Detail</h2>
</center>

<div id="mainpage">
<table width="90%">
<tr>
<td width="15%" valign="top">
<fieldset style="margin:0 5 0 0">
<legend><img src="Picture/member.gif" width="30" height="30">Manage Member</legend>
<table>
<tr>
<td valign="top">
<a href="memlist.php"><img src="Picture/list.gif" width="30" height="30" alt="member list"><a href="memlist.php">Member List</a><br/>
<br/>
<a href="newmem.php"><img src="Picture/add.gif" width="30" height="30" alt="approve member"><a href="newmem.php">Approve Member</a><br/>
<br/>
</td>
</tr>
</table>
</fieldset>
</td>

<td width="75%">
<?php

echo "<form name='memprofile' method='post'>";
include ("connect.php");



$memLname=$_GET['memLname'];

$result = mysql_query("SELECT * FROM member WHERE memLname = '$memLname'");

$row = mysql_fetch_array($result);

echo "<fieldset style='width:80%' align='center'>";
echo "<legend><img src='Picture/member.gif' width='30' height='30'><b>New Member Information</b></legend><br>";

echo "<table width='80%' cellspacing='0' cellpadding='5' border='0' align='center'>";
echo "<tr>";
echo "<td></td>"; 
echo "<td>Login Name</td>"; 
echo "<td><input type='hidden' name='memLname' value=".$row["memLname"].">".$row["memLname"]."";
echo "</td>";
echo "</tr>";
		
echo "<tr>"; 
echo "<td valign='top'></td>";
echo "<td valign='top'>Name</td>"; 
echo "<td><input type='hidden' name='memName' value=".$row["memName"]."><input type='hidden' name='memPassword' value=".$row["memPassword"].">".$row["memName"].""; 
echo "</tr>";

echo "<tr>";
echo "<td valign='top'></td>";
echo "<td valign='top'>NRIC</td>";
echo "<td><input type='hidden' name='memICDate' value=".$row["ICDate"].">".$row["ICDate"]."-";
echo "<input type='hidden' name='memICState' value=".$row["ICState"].">".$row["ICState"]."-";
echo "<input type='hidden' name='memICNo' value=".$row["ICNo"].">".$row["ICNo"]."";
echo "</tr>";
		
echo "<tr>";
echo "<td></td>";
echo "<td valign='top'>Date of Birth<br/>(DD/MM/YYYY):	</td>";
echo "<td>"; 
echo "<input type='hidden' name='memBdate' value=".$row["memBdate"].">".$row["memBdate"]."";
echo "</tr>";
		
echo "<tr>";
echo "<td></td>";
echo "<td>Gender:</td>";
echo "<td><table border='0'>";
echo "<tr><td><input type='hidden' name='memSex' value=".$row["memSex"].">".$row["memSex"]."</td></tr>";
echo "</table>";
echo "</tr>";
			
echo "<tr>";
echo "<td valign='top'></td>";
echo "<td valign='top'>Race:</td>";
echo "<td><input type='hidden' name='memRace' value=".$row["memRace"].">".$row["memRace"]."</td>";
echo "</tr>";
			
echo "<tr>";
echo "<td valign='top'></td>";
echo "<td valign='top'>Address :</td>";
echo "<td valign='top'><input type='hidden' name='memAddress' value=".$row["memAddress"].">".$row["memAddress"]."</td>";
echo "</tr>";
			
echo "<tr>";
echo "<td valign='top'></td>";
echo "<td valign='top'>Post Code :</td>";
echo "<td><input type='hidden' name='memPcode' value=".$row["memPcode"].">".$row["memPcode"]."</td>";
echo "</tr>";

echo "<tr>";
echo "<td valign='top'></td>";
echo "<td valign='top'>City :</td>";
echo "<td><input type='hidden' name='memCity' value=".$row["memCity"].">".$row["memCity"]."</td>";
echo "</tr>";

echo "<tr>";
echo "<td valign='top'></td>";
echo "<td valign='top'>State :</td>";
echo "<td><input type='hidden' name='memState' value=".$row["memState"].">".$row["memState"]."</td>";
echo "</tr>";
		
echo "<tr>";
echo "<td valign='top'></td>";
echo "<td valign='top'>Contact :</td>";
echo "<td><table>";
echo "<tr><td>Home :</td>";
echo "<td><input type='hidden' name='memHnum1' value=".$row["memHnum1"].">".$row["memHnum1"]."-";
echo "<input type='hidden' name='memHnum2' value=".$row["memHnum2"].">".$row["memHnum2"]."</td>";
echo "</tr>";
echo "<tr>";
echo "<td>Handphone :</td>";
echo "<td><input type='hidden' name='memHpnum1' value=".$row["memHpnum1"].">".$row["memHpnum1"]."-";
echo "<input type='hidden' name='memHpnum2' value=".$row["memHpnum2"].">".$row["memHpnum2"]."";
echo "</td>";
echo "</table></td>";
echo "</tr>";
echo "</tr>";
echo "<tr>";
echo "<td></td>";
echo "<td valign='top'>Email :</td>";
echo "<td><input type='hidden' name='memEmail' value=".$row["memEmail"].">".$row["memEmail"]."";
echo "</tr>";
		
		
echo "<tr>";
echo "<td></td>";
echo "<td></td>";
echo "<td><br>";
echo "<input type='submit' name='Approve' value='Approve'/>";
echo "<INPUT TYPE='button' VALUE='Back' onClick='history.go(-1);return true;'/>";
echo "</td>";
echo "</tr>";
	
echo "</table>";
echo "</fieldset>";
echo "</form>";
}else{
	echo "<script language='javascript'>alert ('Please login.')</script>";
	echo "<script language='javascript'>window.location='index.php'</script>";
}
?>
</td>
</tr>
</table>
<hr/>

<center>
<div id="bottom">
<br/>
Copyright &#169; with Tian Tian Bookstore 2011. All Rights Reserved.
<br/>
Website:<a href="../bookstore" target="_blank">www.dailybook.com.my
</div>
</center>

</body>
</html>