1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138
| <?php
require_once("../functions.php");
$username='';
if(isset($_GET['username']))
$username = sanitize($_GET['username']);
try {
$query = $pdo->prepare("SELECT * FROM user WHERE username=:username");
$query->execute(array("username" => $username)); //*
$result = $query->fetch();
} catch (Exception $e) { //*
die("Problème lors de l'accès a la base de données22");
}
$fullname = $result['fullname'];
$email = $result['email'];
$dateofbirth = $result['birthdate'];
$role = $result['role'];
$id = $result['id'];
if (isset($_POST['username']) && isset($_POST['password']) && isset($_POST['password_confirm']) && isset($_POST['fullname']) && isset($_POST['email']) && isset($_POST['dateofbirth']) && isset($_POST['role'])) {
$username2 = sanitize($_POST['username']);
$password2 = sanitize($_POST['password']);
$password_confirm2 = sanitize($_POST['password_confirm']);
$fullname2 = sanitize($_POST['fullname']);
$email2 = sanitize($_POST['email']);
$dateofbirth2 = sanitize($_POST['dateofbirth']);
$role2 = sanitize($_post['role']);
if (trim($username2) == '')
$errors[] = "Le nom d'utilisateur est obligatoire";
if (trim($password2) == '')
$errors[] = "Le mot de passe est obligatoire";
if ($password2 != $password_confirm2)
$errors[] = "Les mots de passe doivent être identiques";
if (trim($fullname2) == '')
$errors[] = "Le nom plein est obligatoire";
if (trim($emai2l) == '')
$errors[] = "L'email est obligatoire";
if (strlen(trim($password2)) < 6)
$errors[] = "Le mot de passe doit contenir 6 caractères au minimum";
if (strlen(trim($username2)) < 6)
$errors[] = "Le nom d'utilisateur doit contenir 6 caractères au minimum";
if (!isset($errors)) {
try {
$query = mysql_query("UPDATE user set username='$username2' ,password ='$password2' ,fullname ='$fullname2' , email ='$email2', birthdate='$dateofbirth2 role='$role2' where id ='$id'");
if($query)
//$success = "Le profil a été mis à jour";
echo "modifier";
} catch (Exception $ex) {
die("Problème lors de l'accès a la base de données123");
}
}
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Sign up</title>
<meta charset="utf-8"/>
<meta name="viewport" content="width=devide-width, initial-scale=1.0">
<link rel="stylesheet" href='../css/style.css' type="text/css">
</head>
<body>
<div class="main">
<div class ="title">
<h1>Bibliothèque de César</h1>
</div>
<div class="signup">
<div class="form-signup">
<div class="login-title">
<h1>Edit profile</h1>
</div>
<form action="<?php echo $_SERVER['PHP_SELF'] ?>" method="post">
<table>
<tr class=" signuptable">
<td>Username:</td>
<td><input id="username" name="username" type="text" value="<?php echo $username; ?>"></td>
</tr>
<tr class=" signuptable">
<td>Fullname:</td>
<td><input id="fullname" name="fullname" type="text" value="<?php echo $fullname; ?>"></td>
</tr>
<tr class=" signuptable">
<td>Password:</td>
<td><input id="password" name="password" type="password"></td>
</tr>
<tr class=" signuptable">
<td>Confirm Password:</td>
<td><input id="password_confirm" name="password_confirm" type="password"></td>
</tr>
<tr class=" signuptable">
<td>email:</td>
<td><input id="email" name="email" type="email" value="<?php echo $email; ?>"></td>
</tr>
<tr class=" signuptable">
<td>Birthdate:</td>
<td><input id="dateofbirth" name="dateofbirth" type="date" value="<?php echo $dateofbirth; ?>"></td>
</tr>
<tr class=" signuptable">
<td>Role:</td>
<td><select>
<option>admin</option>
<option>manager</option>
<option>membre</option></select></td>
</tr>
</table>
<div class="form-btn">
<button type="submit" class="btn-validate">Submit</button>
</div>
</form>
<?php
if (isset($success)) {
echo "<div class ='success'>" . $success . "</div>";
}
if (isset($errors)) {
echo "<div class ='errors'><br><br><p>Veuillez corriger les erreurs: </p>
<ul>";
foreach ($errors as $error) {
echo "<li>" . $error . "</li>";
}
echo '</ul></div>';
}
?>
</div>
</div>
<footer class="footer">
<p>© 2018 Fontaine César, All Rights Reserved</p>
</footer>
</div>
</body>
</html> |
Partager