Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- require 'core/includes.php';
- if(isset($_SESSION['Auth']['id']))
- {
- header('Location:'. WEBROOT .'check.php');
- }
- // Traitement du formulaire de connexion
- if (isset($_GET['form-connexion'])){
- if(isset($_POST['email']) && isset($_POST['password']))
- {
- $email = addslashes(htmlspecialchars(trim($_POST['email'])));
- $password = sha1($_POST['password']);
- $req = $db->query("SELECT * FROM moneyz WHERE users = '$users' AND password = '$password'");
- $count = $req->rowCount();
- if($count == 1)
- {
- $_SESSION['Auth'] = $req->fetch();
- header('Location:'. WEBROOT .'check.php');
- }else{
- $messageConnexion = 'Cet identifiant ou mot de passe n\'existe pas.';
- }
- }else{
- $messageConnexion = 'Vous devez remplir tous les champs.';
- }
- }
- // Traitement du formulaire d'ouverture de compte
- if (isset($_GET['form-create'])){
- if(isset($_POST['email']) && isset($_POST['email_check']) && isset($_POST['password']) && isset($_POST['password_check']))
- {
- $email = addslashes(htmlspecialchars(trim($_POST['email'])));
- $email_check = addslashes(htmlspecialchars(trim($_POST['email_check'])));
- $password = sha1($_POST['password']);
- $password_check = sha1($_POST['password_check']);
- $code = mt_rand(100000000, 900000000);
- $key = mt_rand(1945, 900000000);
- $users = "ID-".$key;
- if($password == $password_check)
- {
- if(preg_match("#^[a-z0-9._-]+@[a-z0-9._-]{2,}\.[a-z]{2,4}$#", $email))
- {
- if($email == $email_check)
- {
- $req = $db->query("SELECT email FROM moneyz WHERE email = '$email'");
- $count = $req->rowCount();
- if($count == 0)
- {
- $req = $db->prepare("INSERT INTO moneyz SET users=?, email=?, password=?, verif_account=?");
- $req->execute(array($users, $email, $password, $code));
- $to = $email;
- $subject = '[ 12345euro.com] Activation compte';
- $message = '
- <html>
- <head>
- </head>
- <body>
- votre clé d\'activation : '.$code.'
- votre email : '.$email.' <br />
- votre mot de passe : Vous le connaissez
- votre ID : '.$users.'
- </body>
- </html>
- ';
- $headers = 'MIME-Version: 1.0' . "\r\n";
- $headers .= 'Content-type: text/html; charset=utf-8' . "\r\n";
- $headers .= 'To:'.$pseudo.' <'.$email.'>' . "\r\n";
- $headers .= 'From: 12345euro.com <register@12345euro.com>' . "\r\n";
- mail($to, $subject, $message, $headers);
- header('Location: waiting.php');
- }else{
- $messageCreate = 'Cette adresse e-mail est déjà utilisée par un autre utilisateur.';
- }
- }else{
- $messageCreate = 'Cet email est déjà utilisé par un autre utilisateur.';
- }
- }else{
- $messageCreate = 'Les deux champs concernant votre adresse email ne sont pas identiques';
- }
- }else{
- $messageCreate = 'Votre adresse email n\'est pas valide.';
- }
- }else {
- $messageCreate = 'Les champs concernant votre mot de passe ne sont pas identiques.';
- }
- }else{
- $messageCreate = 'Vous devez remplir tout les champs.';
- // Fin du traitement du formulaire //
- }
- ?>
- <!doctype html>
- <html lang="fr">
- <head>
- <meta charset="utf-8">
- <title></title>
- <link rel="stylesheet" href="css/style.css">
- <script src=""></script>
- </head>
- <body>
- <form action="index.php?form-connexion" method="post">
- <input name="users" type="text" class="input-form" placeholder="Votre ID..."/>
- <input name="password" type="password" class="input-form" placeholder="Votre mot de passe..."/>
- <button type="submit" class="btn-form">Connexion</button>
- </form>
- <form action="index.php?form-create" method="post">
- <input name="email" type="email" class="input-form" placeholder="Votre email..."/>
- <input name="email_check" type="email" class="input-form" placeholder="Retapez votre email..."/>
- <input name="password" type="password" class="input-form" placeholder="Mot de passe..."/>
- <input name="password_check" type="password" class="input-form" placeholder="Retaper votre mot de passe..."/>
- <button type="submit" class="btn-form">Créer</button>
- </form>
- <div class="imsg"><?= $messageConnexion; $messageCreate; ?></div>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement