<?php
session_start();
include "logo.php";
date_default_timezone_set("Europe/Athens");
if (!(isset($_SESSION['teacherid']) || $_SESSION['teacherid'] == '')) {
    header("location:loginguest.php");
}
$menu=$_SESSION['menu'];
?>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf8" />
</head>
<body> 

<br >
<br >
<br >
<form name="form1" method="post"  >
<td>
<table width="400" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF">
<tr>
<td colspan="3"><strong>ΑΛΛΑΓΗ ΚΩΔΙΚΟΥ ΠΡΟΣΒΑΣΗΣ </strong></td>
</tr>
<tr>
<td colspan="3"></td><?php echo "Ημερομηνία: ".date('d-m-Y');?> </td>
</tr>
<tr>
<td width="160">Νέος Κωδικός :</td>
<td width="6">:</td>
<td width="194"><input name="newpass" type="password" id="newpass"></td>
</tr>
<tr>
<td>Επιβεβαίωση Κωδικού :</td>
<td>:</td>
<td><input name="confpass" type="password" id="confpass"></td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td><input name="passch" type="submit" value="Αλλαγή Κωδικού"></td>
</tr>
</table>
</form>

<?php

if (isset($_POST['passch'])) {
include "dbconnect.php";

$password1 = mysqli_real_escape_string($con, $_POST['newpass']);
$password2 = mysqli_real_escape_string($con, $_POST['confpass']);
$usr = mysqli_real_escape_string($con, $_SESSION['studentid']);

if ($password1 <> $password2) { echo "ΟΙ ΚΩΔΙΚΟΙ ΣΑΣ ΔΕΝ ΣΥΜΠΙΠΤΟΥΝ";}

else 
{
	$hash = password_hash($password1, PASSWORD_DEFAULT);
	if (mysqli_query($con, "UPDATE parents SET password='$hash' WHERE username='$usr'"))
    {echo "ΕΧΕΤΕ ΑΛΛΑΞΕΙ ΤΟΝ ΚΩΔΙΚΟ ΣΑΣ ΜΕ ΕΠΙΤΥΧΙΑ";}

else { mysqli_error($con); }
}
mysqli_close($con);

header("location: indexparent.php ");

}

?>
<br /><br /><br />
<a  href=<?php echo $menu;?> style="color:blue "  >  Επιστροφή </a>
</body>
</html>








