<?php
session_start();
require_once('config.php');
$url='connexion.php';
if(!isset($_SESSION['connected'])){
echo '<script type="text/javascript">window.location="'.$url.'";</script>';
header('location: connexion.php');
exit();
}
$userImage=$_GET["name"];//user personal Image
if(!preg_match('#'.$_SESSION['pseudo'].'#',$userImage)) header('location: preferences.php');
$container="password";
?>
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<link rel="stylesheet" href="assets/css/style.css">
<title>Add an Account Password</title>
<style>
<?php echo ((helpuser!=true)?" #clictoconnect td {border: none; }":"");?>
</style>
<!--<script src="./jquery-ui-1.12.1/external/jquery/jquery.js"></script>-->
<script src='http://code.jquery.com/jquery.js'></script>
</head>
<body>
<div id="content">
<p><hr/>| Welcome <span id="pseudo"><?php echo strtoupper($_SESSION["pseudo"]);?></span> | <a href="dologout.php" class="none">Log out</a> | <a href="preferences.php" class="none">Preferences</a> |<hr/></p>
<form method="POST" id="test" >
<fieldset>
<legend>Add a click to connect password</legend>
<div class="instruction">
<p>Click on the picture to create an account password</p>
</div>
<?php require_once('src/ctc.php');?>
<p><input type="hidden" id="use" name="use"/></p>
<p><input type="hidden" id="user-id" name="user_id" value="<?php echo ((isset($_SESSION['user_id']))?$_SESSION['user_id']:'');?>" disabled="disabled"/></p>
<p><input type="hidden" id="path" name="path" value="<?php echo $userImage;?> " disabled="disabled"/> </p>
<p><input type="submit" value="Submit"> <input type="reset" value="Reset"></p>
</div></fieldset>
</form>
</div>
<script>
jQuery(document).ready(function($){
$('#test').submit(function(e){ e.preventDefault(); $("#failed").html("<p>Wait while connecting...<br/><img src='assets/img/loader.gif' alt='Uploading....'/></p>"); $.post('addapass.php', { path : $("#path").val(),use : $("#use").val(), userid : $("#user-id").val(), password : $("#password").val() }, function(data){
if(data.trim() == 'Success'){
$("#failed").html("");
$("#resultat").html("<p>New click to connect password successfully added!Wait while redirecting...</p>");
setInterval(window.location="preferences.php",15000);
}
else{
$("#resultat").html("");
$("#failed").html("<p>An error occured please try again later</p>");
}
}, 'text' ); });
});
</script>
</body>
</html>
|