<?php

session_start();

include "../config.php";
include "../header.php";
include "../style.php";
//if( isset($_SESSION["alogin"]) ) {

$useridpp = dbput($_POST['userid']);
$passwordp = dbput($_POST['password']);
$namep = dbput($_POST['name']);
$lastnamep = dbput($_POST['lastname']);
$contact_emailp = dbput($_POST['contact_email']);
$subscribed_emailp = dbput($_POST['subscribed_email']);
$paypal_emailp = dbput($_POST['paypal_email']);
$alertpay_emailp = dbput($_POST['alertpay_email']);
$safepay_emailp = dbput($_POST['safepay_email']);
$moneybookers_emailp = dbput($_POST['moneybookers_email']);
$statusp = dbput($_POST['status']);
$referidp = dbput($_POST['referid']);
$commissionp = dbput($_POST['commission']);
$pointsp = dbput($_POST['points']);
$ticketsp = dbput($_POST['tickets']);
$vacationp = $_POST['vacation'];

if( session_is_registered("alogin") ) {
?><table>
<tr>
<td width="15%" valign=top><br>
<? include("adminnavigation.php"); ?>
</td>
<td  valign="top" align="center"><br><br> <?
echo "<font size=2 face='$fonttype' color='$fontcolour'><p><b><center>";
// errorchecking first:

if (empty($password)) {
echo "Error! Password field is empty.";
?>
<center>
<form method="POST" action="edit.php">
<input type="hidden" name="userid" value="<? echo $userid; ?>">
<input type="submit" value="Go Back To Edit '<? echo $userid; ?>'">
</form>
</center>
<?
exit;
}
if (empty($name)) {
echo "Error! Name field is empty.";
?>
<center>
<form method="POST" action="edit.php">
<input type="hidden" name="userid" value="<? echo $userid; ?>">
<input type="submit" value="Go Back to Edit '<? echo $userid; ?>'">
</form>
</center>
<?
exit;
}

if (empty($name)) {
        echo "Error! Name field is empty.";
        ?>
            <center>
	        <form method="POST" action="edit.php">
	        <input type="hidden" name="userid" value="<? echo $userid; ?>">
            <input type="submit" value="Go Back to Edit '<? echo $userid; ?>'">
	        </form>
	        </center>
	    <?
        exit;
        }

$query = "UPDATE members SET ";
$query .= "name='$namep',lastname='$lastnamep',pword='$passwordp',contact_email='$contact_emailp',paypal_email='$paypal_emailp',";
$query .= "subscribed_email='$contact_emailp',vacation='$vacationp',alertpay_email='$alertpay_emailp',safepay_email='$safepay_emailp',moneybookers_email='$moneybookers_emailp',";
$query .= "commission='$commissionp', points='$pointsp', referid='$referidp', tickets='$ticketsp' ";
$query .= "WHERE userid = '$useridpp'";

$result = mysql_query ($query)
or die ("failed");


echo "<center>User Updated.</center>";
?>
<br>
<center>
 <form method="POST" action="edit.php">
<input type="hidden" name="userid" value="<? echo $userid; ?>">
<input type="submit" value="Go Back to Edit '<? echo $userid; ?>'">
</form>
<form method="POST" action="view.php">
<input type="submit" value="Go Back To View Members">
</form>
</center>
<?
echo "</td></tr></table>";
}
else
{
echo "Unauthorised Access!";
}

include "../footer.php";
mysql_close($dblink);
?>