<?
$pagetitle = "Edit User";
include_once('admheader.inc.php');
include_once('../config.php');
$sql_select = "select * from mh_users where user_id ='$user_id'";
if ($debug) { print("$sql_select");}
$result = mysql_query ($sql_select);
while ($row = mysql_fetch_array($result))
{
$user_id = $row["user_id"];
$first_name = $row["first_name"];
$last_name = $row["last_name"];
$dob_day = substr($row["dob"],6,2);
$dob_month = substr($row["dob"],4,2);
$dob_year = substr($row["dob"],0,4);
$sex = $row["sex"];
$user_email = $row["user_email"];
$reg_date = $row["reg_date"];
$activated = $row["activated"];
$reg_year=substr($row["reg_date"],0,4);
$reg_month=substr($row["reg_date"],4,2);
$reg_day=substr($row["reg_date"],6,2);
$notes=$row["notes"];
// if notes is empty diplay nothing (instead of 0)
if (empty($notes)){$notes="";}
}
if (!$submit) {
print "<p>Our database holds the following information about $first_name $last_name.</p><blockquote>Below you may edit his/her profile ban users and reactivate already banned users.</blockquote>";
if ($activated== '0')
{
$status = "Awaiting activation";
}
if ($activated== '1')
{
$status = "Active";
}
?>
<form name="edit_user" method="post" action="edit_user.php">
<table width="400" border="1" cellspacing="0" cellpadding="0" bordercolor="#98BEDE" align="center">
<tr bgcolor="#98BEDE">
<td><b><font size="4">User Profile</font></b>
<table width="400" border="0" cellspacing="1" cellpadding="4" align="center">
<tr bgcolor="#DCEAF5">
<td width="200"><b>First name: </b></td>
<td width="200">
<input type="text" class="textbox" name="first_name" maxlength="25" value="<? echo"$first_name";?>">
</td>
</tr>
<tr bgcolor="#CADEEE">
<td width="200"><b>Last name: </b></td>
<td width="200">
<input type="text" class="textbox" name="last_name" maxlength="25" value="<? echo"$last_name";?>">
</td>
</tr>
<tr bgcolor="#DCEAF5">
<td width="200"><b>Sex: </b></td>
<td width="200">
<select name="sex" class="textbox">
<? if ($sex =="M") {?>
<option value="<?echo $sex?>" selected>Male</option>
<option value="F">Female</option><? }
if ($sex =="F") {?>
<option value="<?echo $sex?>" selected>Female</option>
<option value="M">Male</option><? }?>
</td>
</tr>
<tr bgcolor="#CADEEE">
<td width="200"><b>DOB: </b></td>
<td width="200">
<input type="text" class="textbox" name="dob" maxlength="8" size="8" value="<? echo"$dob_day$dob_month$dob_year";?>"><br>
<?print "<font size='1'>Format: DDMMYYYY</font>"?>
</td>
</tr>
<tr bgcolor="#DCEAF5">
<td width="200"><b>Email address: </b></td>
<td width="200">
<input type="text" class="textbox" name="user_email" maxlength="25" value="<? echo"$user_email";?>"
</td>
</tr>
<tr bgcolor="#CADEEE">
<td width="200"><b>Registration Date: </b></td>
<td width="200">
<?print "$reg_day-$reg_month-$reg_year"?>
</td>
</tr>
<tr bgcolor="#DCEAF5">
<td width="200"><b>Account status:</b> </td>
<td width="200">
<?if ($activated ==0){
print "Awaiting activation"; }
else { ?>
<select name="activated" class="textbox">
<? if ($activated ==1) {?>
<option value="<?echo $activated?>" selected>Active</option>
<option value=2>Ban User</option></select><br>
<font size="1">Use this option to ban users</font><? }
if ($activated ==2) {?>
<option value="<?echo $activated?>" selected>Banned</option>
<option value=1>Re-Activate</option></select><br>
<font size="1">Use this option to reactivate banned users</font><?}}?>
</td>
</tr>
<tr bgcolor="#CADEEE">
<td width="200"><b>User notes:</b><br><font size="1">Here you may store any notes concerning this user. For example why their account may be banned.</font></td>
<td width="200"><textarea name="notes" class="textbox" cols="45" rows="4"><?echo "$notes"?></textarea></td></tr>
<tr bgcolor="#DCEAF5">
<td width="200"></td>
<td width="200"><input type="submit" class="submit" name="submit" value="Save Changes"></td></tr>
</table>
</td>
</tr>
</table>
</form>
<p align="center"><a href = "javascript:history.back()">Return to previous page</a></p>
<?
}
if ($submit) {
$sql_update = "update perscriptions set user_id='$user_id', first_name='first_name', last_name='last_name', sex='$sex', dob='$dob', user_email=$user_email, activated='$activated', notes='$notes' where user_id='$user_id'";
print "<p>User profile has been updated successfully</p>"; }
include_once('admfooter.inc.php');
?>