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 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169
| <?php
session_start();
$bdd = new PDO('mysql:host=localhost;dbname=u884437960_em', 'u884437960_rm', 'taxregri');
if(isset($_POST['formconnexion'])) {
$mailconnect = htmlspecialchars($_POST['mailconnect']);
$pseudoconnect = htmlspecialchars($_POST['pseudoconnect']);
$mdpconnect = sha1($_POST['mdpconnect']);
if(!empty($pseudoconnect) OR !empty($mailconnect) AND !empty($mdpconnect)) {
$requser = $bdd->prepare("SELECT * FROM membres WHERE mail = ? OR pseudo = ? AND motdepasse = ?");
$requser->execute(array($pseudoconnect, $mailconnect, $mdpconnect));
$userexist = $requser->rowCount();
if($userexist == 1) {
$userinfo = $requser->fetch();
$_SESSION['id'] = $userinfo['id'];
$_SESSION['pseudo'] = $userinfo['pseudo'];
$_SESSION['mail'] = $userinfo['mail'];
header("Location: actu.php?id=".$_SESSION['id']);
} else {
$erreurlogin = "Mauvaise pseudo ou mauvais mot de passe !";
}
} else {
$erreurlogin = "Tous les champs doivent être complétés !";
}
}
?>
<?php
$bdd = new PDO('mysql:host=localhost;dbname=bdd', 'utilisateur', 'mdp');
if(isset($_POST['forminscription'])) {
$pseudo = htmlspecialchars($_POST['pseudo']);
$mail = htmlspecialchars($_POST['mail']);
$mdp = sha1($_POST['mdp']);
$mdp2 = sha1($_POST['mdp2']);
if(!empty($_POST['pseudo']) AND !empty($_POST['mail']) AND !empty($_POST['mdp']) AND !empty($_POST['mdp2'])) {
$pseudolength = strlen($pseudo);
if($pseudolength <= 255) {
if($mail) {
if(filter_var($mail, FILTER_VALIDATE_EMAIL)) {
$reqmail = $bdd->prepare("SELECT * FROM membres WHERE mail = ?");
$reqmail->execute(array($mail));
$mailexist = $reqmail->rowCount();
if($mailexist == 0) {
if($mdp == $mdp2) {
$insertmbr = $bdd->prepare("INSERT INTO membres(pseudo, mail, motdepasse) VALUES(?, ?, ?)");
$insertmbr->execute(array($pseudo, $mail, $mdp));
$erreur = "Votre compte a bien été créé !</a>";
} else {
$erreur = "Vos mots de passes ne correspondent pas !";
}
} else {
$erreur = "Adresse email déjà utilisée !";
}
} else {
$erreur = "Votre adresse email n'est pas valide !";
}
}
} else {
$erreur = "Votre pseudo ne doit pas dépasser 255 caractères !";
}
} else {
$erreur = "Tous les champs doivent être complétés !";
}
}
?>
<html>
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="initial-scale=1.0; maximum-scale=1.0" />
<title>FriendsNetwork - Réseau social privé</title>
<meta name="viewport" content="width=device-width, target-densitydpi=device-dpi, initial-scale=1"/>
<link rel="icon" type="image/png" href="images/favicon.png">
<link rel="stylesheet" type="text/css" href="index.css" />
<link href='https://fonts.googleapis.com/css?family=Dancing+Script:400,700' rel='stylesheet' type='text/css'>
</head>
<body>
<body>
<div id="bande">
<center><h2><strong><font color="#19c589">FriendsNetwork</font></strong></h2></center>
<blockquote>
<p style="margin-bottom: 0px;">Mon premier réseau social privé.</p>
<div id="author" style="width: 115px;"></div>
</blockquote>
</div>
<div="solution">
<div class="solution_image">
</div>
<div class="solution_interieur">
<h2 class="interieur_title" margin-left="200px;" style="margin-left: 50px;"><font color="#E65555">Se connecter</font></h2>
<p style="margin-left: 100px; margin-top: 50px;">
<form method="POST" action="" style="margin-left: 40px;">
Pseudo: <input type="text" name="mailconnect" name="pseudoconnect" placeholder="Votre pseudo" /><br />
Mot de Passe : <input type="password" name="mdpconnect" placeholder="Votre mot de passe" />
<br /><br />
<input type="submit" name="formconnexion" value="Se connecter" />
</form>
<?php
if(isset($erreur)) {
echo $erreurlogin;
}
?>
</p>
</form>
</div>
<div id="register">
<h2 class="register_title" style="width: 110px;"><font color="#46A2D9">S'inscrire</font></h2>
<p style="margin-right: 200px; margin-top: 50px;">
<div id="formregister" style="/* width: 550px; */width: 550px;">
<form method="POST" action="">
<table>
<tr>
<td align="right">
<label for="pseudo"><h2>Pseudo : </h2></label>
</td>
<td>
<input type="text" placeholder="Nom et Prénom" id="pseudo" name="pseudo" value="<?php if(isset($pseudo)) { echo $pseudo; } ?>" />
</td>
</tr>
<tr>
<td align="right">
<label for="mail"><h2>Email : </h2></label>
</td>
<td>
<input type="email" placeholder="Votre email" id="mail" name="mail" value="<?php if(isset($mail)) { echo $mail; } ?>" />
</td>
</tr>
<tr>
<td align="right">
<label for="mdp"><h2>Mot de passe : </h2></label>
</td>
<td>
<input type="password" placeholder="Votre mot de passe" id="mdp" name="mdp" />
</td>
</tr>
<tr>
<td align="right">
<label for="mdp2"><h2>Confirmation du mot de passe : </h2></label>
</td>
<td>
<input type="password" placeholder="Confirmez votre mot de passe" id="mdp2" name="mdp2" />
</td>
</tr>
<tr>
<td></td>
<td align="center">
<br />
<input type="submit" name="forminscription" value="Je m'inscris" />
</td>
</tr>
</table>
</form>
<?php
if(isset($erreur)) {
echo $erreur;
}
?>
</div>
</p>
</div>
<br>
</div="solution">
<br />
</body>
<footer>
<?php include("footer.php"); ?>
</footer>
</html> |
Partager