| Current Path : /var/www/cesa.co.za/cesanet/ |
| Current File : /var/www/cesa.co.za/cesanet/password.php |
<?php
include("inc_functions.php");
//ini_set('display_errors', 1);
//error_reporting(E_ALL);
if (!isset($_SESSION["StudentID"]) || empty($_SESSION["StudentID"]) || $_SESSION["StudentID"] == null)
header("Location: /cesanet/login.php");
include_once($_SERVER['DOCUMENT_ROOT'] . "/cesanet/includes/html_begin.php");
?>
<h1> Change Password:</h1>
<?php
if (isset($_POST["go"]) && ($_POST["go"] == 1)) {
$sql = "SELECT WebPassword FROM CCEStudents WHERE CCEStudentID=" . $_SESSION["StudentID"];
$rec = mysql_query($sql);
if ($row = mysql_fetch_assoc($rec)) {
if (empty($_POST["Current"]) || empty($_POST["NewPassword1"]) || empty($_POST["NewPassword2"])) {
echo "<div class\"alert alert-danger\">ERROR: Please complete all the fields below.</div>";
} elseif ($_POST["Current"] != $row["WebPassword"]) {
echo "<div class\"alert alert-danger\">ERROR: Your current password is incorrect.</div>";
} elseif ($_POST["NewPassword1"] != $_POST["NewPassword2"]) {
echo "<div class\"alert alert-danger\">ERROR: The two new passwords do not match.</div>";
} else {
$sql = "UPDATE CCEStudents SET WebPassword='" . addslashes($_POST["NewPassword1"]) . "' WHERE CCEStudentID=" . $_SESSION["StudentID"];
mysql_query($sql);
echo "<div class\"alert alert-success\">Your password has been updated.</div>";
}
}
}
?>
<form id="form1" name="form1" method="post" action="password.php">
<input type="hidden" name="go" value="1">
<table border="0" cellpadding="5" cellspacing="0" class="table">
<tbody>
<tr>
<td>Current password:</td>
<td><input name="Current" type="password" id="Current" class="form-control" /></td>
</tr>
<tr>
<td width="10%"><p>New password:</p></td>
<td>
<input name="NewPassword1" type="password" id="NewPassword1" class="form-control" />
</td>
</tr>
<tr>
<td><p>Confirm new password:</p></td>
<td><input name="NewPassword2" type="text" id="NewPassword2" class="form-control" /></td>
</tr>
</tbody>
</table>
<div class="row p-3">
<div class="d-grid gap-2 d-md-block text-center">
<input type="submit" name="button" id="button" class="btn btn-primary" value="Update Now" />
</div>
</div>
</form>
<?php
include_once($_SERVER['DOCUMENT_ROOT'] . "/cesanet/includes/html_end.php");