| Current Path : /var/www/cesa.co.za/mentanet/ |
| Current File : /var/www/cesa.co.za/mentanet/password.php |
<?php
include("inc_functions.php");
if (!isset($_SESSION["StudentID"]) || empty($_SESSION["StudentID"])) header("Location: http://www.cesa.co.za/mentanet/login.php");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>MentaNet</title>
<link href="style.css" rel="stylesheet" type="text/css" />
<!--[if IE 5]>
<style type="text/css">
/* place css box model fixes for IE 5* in this conditional comment */
.twoColFixLtHdr #sidebar1 { width: 230px; }
</style>
<![endif]--><!--[if IE]>
<style type="text/css">
/* place css fixes for all versions of IE in this conditional comment */
.twoColFixLtHdr #sidebar1 { padding-top: 30px; }
.twoColFixLtHdr #mainContent { zoom: 1; }
/* the above proprietary zoom property gives IE the hasLayout it needs to avoid several bugs */
</style>
<![endif]-->
</head>
<body class="twoColFixLtHdr">
<div id="container">
<?php include("inc_header.php"); ?>
<?php include("inc_sidebar.php"); ?>
<div id="mainContent">
<h1> Change Username and Password:</h1>
<?php
$sql = "SELECT * FROM ";
if ($_SESSION["UserType"]=="C") {
$sql.="CCMStudents";
} elseif ($_SESSION["UserType"]=="M") {
$sql.="CCMMentors";
} elseif ($_SESSION["UserType"]=="E") {
$sql.="CCMEmployers";
}
$sql.=" WHERE ";
if ($_SESSION["UserType"]=="C") {
$sql.="CCMStudentID";
} elseif ($_SESSION["UserType"]=="M") {
$sql.="CCMMentorID";
} elseif ($_SESSION["UserType"]=="E") {
$sql.="CCMEmployerID";
}
$sql.="=".$_SESSION["StudentID"];
$rec = mysql_query($sql);
$row = mysql_fetch_assoc($rec);
$sCurrentUser=$row["WebUsername"];
$sCurrentPwd=$row["WebPassword"];
if (isset($_POST["go"]) && ($_POST["go"]==1)) {
if ($sCurrentPwd!=$_POST["password1"]) {
echo "<p><b style='color:red'>ERROR: The password you entered does not match your current password.</b></p>";
} elseif (empty($_POST["username2"])) {
echo "<p><b style='color:red'>ERROR: You must specify a username.</b></p>";
} elseif (empty($_POST["password2"])) {
echo "<p><b style='color:red'>ERROR: You must specify a new password.</b></p>";
} elseif (strlen($_POST["password2"])<8) {
echo "<p><b style='color:red'>ERROR: Your new password must be at least 8 characters long.</b></p>";
} else {
$sql = "SELECT * FROM ";
if ($_SESSION["UserType"]=="C") {
$sql.="CCMStudents";
} elseif ($_SESSION["UserType"]=="M") {
$sql.="CCMMentors";
} elseif ($_SESSION["UserType"]=="E") {
$sql.="CCMEmployers";
}
$sql.=" WHERE ";
if ($_SESSION["UserType"]=="C") {
$sql.="CCMStudentID";
} elseif ($_SESSION["UserType"]=="M") {
$sql.="CCMMentorID";
} elseif ($_SESSION["UserType"]=="E") {
$sql.="CCMEmployerID";
}
$sql.="<>".$_SESSION["StudentID"]." AND WebUsername='".$_POST["username2"]."'";
$rec = mysql_query($sql);
if (mysql_num_rows($rec)>0) {
echo "<p><b style='color:red'>ERROR: The username you have chosen already exists.</b></p>";
} else {
$sql = "UPDATE ";
if ($_SESSION["UserType"]=="C") {
$sql.="CCMStudents";
} elseif ($_SESSION["UserType"]=="M") {
$sql.="CCMMentors";
} elseif ($_SESSION["UserType"]=="E") {
$sql.="CCMEmployers";
}
$sql.=" SET WebUsername='".$_POST["username2"]."', WebPassword='".$_POST["password2"]."' WHERE ";
if ($_SESSION["UserType"]=="C") {
$sql.="CCMStudentID";
} elseif ($_SESSION["UserType"]=="M") {
$sql.="CCMMentorID";
} elseif ($_SESSION["UserType"]=="E") {
$sql.="CCMEmployerID";
}
$sql.="=".$_SESSION["StudentID"];
mysql_query($sql);
echo "<p><b>SUCCESS: Your username and password have been updated to:<br></b>
Username: ".$_POST["username2"]."<br>
Password: ".$_POST["password2"]."</p>";
}
}
}
?>
<form id="form1" name="form1" method="post" action="password.php">
<input type="hidden" name="go" value="1" />
<table border="0" cellpadding="5" cellspacing="0">
<tbody>
<tr>
<td>Current username:</td>
<td><?php echo $sCurrentUser; ?></td>
</tr>
<tr>
<td>New username:</td>
<td><input name="username2" type="text" id="username2" size="50" value="<?php echo $sCurrentUser; ?>" /></td>
</tr>
<tr>
<td>Current password:</td>
<td><input name="password1" type="text" id="password1" size="50" /></td>
</tr>
<tr>
<td width="203" valign="top"><p>New password:</p></td>
<td width="379"><p>
<input name="password2" type="text" id="password2" size="50" /><br />
Must be at least 8 characters long
</p></td>
</tr>
</tbody>
</table>
<p>
<label>
<input type="submit" name="button" id="button" value="Update Now" />
</label>
</p>
</form>
<p> </p>
</div>
<?php include("inc_footer.php"); ?>
<!-- end #container --></div>
</body>
</html>