Location: PHPKode > projects > GolfstatsPHP > golfstatsphp_3.0/changepass.php
<?
include("dbasecon.inc.php");
include("session.inc.php");
include("userfunctions.inc.php");
include ("header.php");



if ($HTTP_POST_VARS['change']) {

//password update
		 $passwordchangesql = "Update users_tour Set password='$reqpassword', Name='$reqname',
		 											Surname='$surname', Age='$age', Handicap='$handicap', homeclub='$homeclub',
													email='$email', phoneno='$phoneno'  
		 										where userid = '$login_id'"; 

		$passwordchangeresult=mysql_query($passwordchangesql);

$error="User profile changed.<p>";


//now lets see if this user originally has WMD
if ($wmdexist) {

//$error="$error <br> Updating your WMD.";
$insertwmdsql="UPDATE `users_clubs` SET driver = '$driver', woods='$woods',irons='$irons',putter='$putter',ball='$ball',bag='$bag' WHERE `userid` = '$login_id'";

$insertwmdquery=mysql_query($insertwmdsql);

} else {

//$error="$error Inserting your WMD.";
$insertwmdsql="INSERT INTO `users_clubs` (`userid`, `driver`, `woods`, `irons`, `putter`, `ball`, `bag`)VALUES ('$login_id', '$driver', '$woods', '$irons', '$putter', '$ball', '$bag')";
$insertwmdquery=mysql_query($insertwmdsql);


} //endif wmdexist

}//endif change


//get the password for current user
$passwordsql="Select *
				from users_tour a1
					where a1.userid = '$login_id'";				
				$passwordquery=mysql_query($passwordsql);
				$passwordrow=mysql_fetch_array($passwordquery);
				$passwordexist=mysql_numrows($passwordquery);


if ($passwordexist) {
extract($passwordrow);


$passwordlen=strlen($password);

for ($i = 1; $i <= $passwordlen; $i++) {
    $asterixpass=$asterixpass."*";
}


} else {
echo "Application Error. Please contact your administrator.";
echo $passwordsql;
exit();
}


//now check if this guy has WMD
$wmdsql="Select *
				from users_clubs a1
					where a1.userid = '$login_id'";				
				$wmdquery=mysql_query($wmdsql);
				$wmdexist=mysql_numrows($wmdquery);

if ($wmdexist) {
$wmdrow=mysql_fetch_array($wmdquery);
extract($wmdrow);
} else {
$driver="NA";
$woods="NA";
$irons="NA";
$putter="NA";
$ball="NA";
$bag="NA";

}//endif wmdexist				
				
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<? showheader("Player Account"); ?>


<h2 class='heading'>Details for <? echo $login_id ?></h2> 
<p>
<? echo $error; ?>

<table border=1>
<tr bgcolor="A8A8A8">
<td>Login</td><td>Password</td><td>Name</td><td>Surname</td><td>Age</td>
<td>Handicap</td><td>Home Club</td><td>Email</td>
<td>Contact</td></tr>
<?

if ($passwordexist) {
//the loop that outputs SQL query into nice tably forms	 
do {

extract($passwordrow);

echo "<form method=\"post\" action=\"$PHP_SELF\" onSubmit=\"return checkrequired(this)\">";


echo "<tr><td><input type=\"Hidden\" name=\"reqlogin\" value=\"$login\">$login</td>";

echo "<td><input type=\"$passtext\" maxlength=\"10\" size=\"10\" name=\"reqpassword\" value=\"$password\" ></td>";


echo "<td><input type=\"text\" maxlength=\"25\" size=\"15\" name=\"reqname\" value=\"$name\"></td>";

echo "<td><input type=\"text\" maxlength=\"25\" size=\"15\" name=\"surname\" value=\"$surname\"  ></td>";
echo "<td><input type=\"text\" maxlength=\"3\" size=\"2\" name=\"age\" value=\"$age\"  ></td>";
echo "<td><input type=\"text\" maxlength=\"2\" size=\"2\" name=\"handicap\" value=\"$handicap\"  ></td>";
echo "<td><input type=\"text\" maxlength=\"50\" size=\"25\" name=\"homeclub\" value=\"$homeclub\"  ></td>";
echo "<td><input type=\"text\" maxlength=\"50\" size=\"25\" name=\"email\" value=\"$email\"  ></td>";
echo "<td><input type=\"text\" maxlength=\"15\" size=\"15\" name=\"phoneno\" value=\"$phoneno\"  ></td>";
echo "</tr>";

/*---------------------------------------*/
echo "</table>";
echo "<p>";

echo "<table border=1 cellpadding=2 cellspacing=5>";
echo "<tr class=bg0><td colspan=2>Weapons of Mass Destruction</td></tr>";
echo "<tr class=bg4><td>Driver</td><td><input type=\"text\" maxlength=\"200\" size=\"100\" name=\"driver\" value=\"$driver\"></td></tr>";
echo "<tr class=bg4><td>Woods</td><td><input type=\"text\" maxlength=\"200\" size=\"100\" name=\"woods\" value=\"$woods\"></td></tr>";
echo "<tr class=bg4><td>Irons</td><td><input type=\"text\" maxlength=\"200\" size=\"100\" name=\"irons\" value=\"$irons\"></td></tr>";
echo "<tr class=bg4><td>Putter</td><td><input type=\"text\" maxlength=\"200\" size=\"100\" name=\"putter\" value=\"$putter\"></td></tr>";
echo "<tr class=bg4><td>Bag</td><td><input type=\"text\" maxlength=\"200\" size=\"100\" name=\"bag\" value=\"$bag\"></td></tr>";
echo "<tr class=bg4><td>Primary Balls</td><td><input type=\"text\" maxlength=\"200\" size=\"100\" name=\"ball\" value=\"$ball\"></td></tr>";

echo "</table>";
echo "<p>";
echo "<input type=\"hidden\" name=\"wmdexist\" value=\"$wmdexist\">&nbsp&nbsp";	   

echo "<input type=\"Submit\" name=\"change\" value=\"Change\">&nbsp&nbsp";	   


echo "</form>";


}while ($passwordrow = mysql_fetch_array($passwordquery)); //end while. Elegant code!
}
?>



<? showfooter(); ?>
Return current item: GolfstatsPHP