<?php include "core/menu.php" ?>
							<br/><br/>
						</div>
					</div>
				</div>
				
				<div class="spacer"></div>				<div class="news">
				<div />
				<div>
				
<h3>Modifier mon mot de passe <br><br>
</h3>
<?php 
error_reporting(0);
include ('config/config.php');
include ('login.php');
mysql_select_db($realmd,$connexion) or die(mysql_error());
		$post = $_SESSION['id'];
			$sql="SELECT * FROM account WHERE id='$post'";
			$resultat=mysql_query($sql) or die ("Erreur requette SQL");
			$info=mysql_fetch_array($resultat);
			$datas2 = mysql_query("SELECT * FROM account WHERE id= '$id'");
$donnees3 = mysql_fetch_array($datas2);
			
if ($_SESSION['logged'] == 1)
echo'				<form action="mpass.php?action=valide_modify" method="POST">
						
							<b>Nom du compte :
							<input readonly disabled type="text" name="username" value="'.$info["username"].'" size="30" maxsize="50"><br />
						
						
							<b>Mot de passe &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:
							<input type="password" name="passnew" value="******" size="30" maxsize="40"><br />
					
					<center><br><input type="submit" value="Modifier"></form><br>
					<a href="membre.php">Retour</a><br><br>';
					else 
					echo 'Vous devez vous connecter pour avoir acces a cette partie du site. <br><br>						
					<form action="?action=connexion" method="post">
						
							<label for="labe25"><center>Nom de compte : </label></center>
							<center><input type="text" name="pseudo"></center>
							<label for="labe26"><center>Mot de passe :</label></center>
							<center><input type="password" name="pass"></center>
							<center><br><input type="submit" value="Connexion" name="connexion">
						</form>';
					switch ($_GET['action'])
					{
					case "valide_modify":
$id = $_SESSION['id'];

if ($donnees1['online'] == 1)
{
?>
<center><p><h3>Vous êtes actuelement connecté en jeu.<h3><h4> merci de vous déconnecter.</h4></p></center>
<?php
}
else
{
		$id = $_SESSION['id'];
		$username = trim(htmlspecialchars($_SESSION['pseudo']));
		$password = $_POST['passnew'];
		mysql_select_db($realmd,$connexion) or die(mysql_error());
			// MODIFIE LE MDP
			mysql_query("UPDATE account SET sha_pass_hash=SHA1(CONCAT(UPPER('$username'),':',UPPER('$password'))) WHERE id='$id'");
			echo "<center><h3>Votre mot de passe a bien été modifié !</h3></center>";
}
break;
}
?>
</div>
					</div>
					<div class="spacer"></div>
				</div>
			</div>

<?php include "core/end.php" ?>