SHARE
TWEET

Regristro.php

benites Apr 1st, 2019 (edited) 133 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. session_start();
  3.  
  4. if(isset($_POST['email']) && empty($_POST['email']) == false) {
  5.     $nome = addslashes($_POST['nome']);
  6.     $email = addslashes($_POST['email']);
  7.     $senha = md5(addslashes($_POST['senha']));
  8.  
  9.  
  10.     $dsn = "mysql:dbname=crypto;host: 127.0.0.1;";
  11.     $dbuser = "root";
  12.     $dbpass = "";
  13.  
  14.     $db = new PDO($dsn, $dbuser, $dbpass);
  15.  
  16.     try {
  17.         $stmt = $db->prepare('INSERT INTO users (nome, email, senha) VALUES (:nome,:email, :senha)');
  18.         $stmt->execute(array(
  19.             ':nome' => $nome,
  20.             ':email' => $email,
  21.             ':senha' => $senha
  22.         ));
  23.  
  24.         $sql = $db->query("SELECT * FROM users WHERE email = '$email'");
  25.  
  26.         if($sql->rowCount()  > 0) {
  27.             $_SESSION['emailexiste'] = 1;
  28.         }elseif ($sql->rowCount()  < 1) {
  29.             $_SESSION['emailexiste'] = 0;
  30.  
  31.  
  32.             $sql = $db->query("SELECT * FROM users WHERE email = '$email' AND senha = '$senha'");
  33.  
  34.  
  35.             if ($sql->rowCount() > 0) {
  36.  
  37.                 $dado = $sql->fetch();
  38.  
  39.                 $_SESSION['id'] = $dado['id'];
  40.                 $nome = $dado['nome'];
  41.                 $_SESSION['email'] = $dado['email'];
  42.  
  43.                 $array = explode(" ", $nome);
  44.                 $_SESSION['nome'] = $array[0];
  45.  
  46.                 header("Location: index.php");
  47.  
  48.             }
  49.  
  50.         }elseif ($email == '') {
  51.             $_SESSION['emailexiste'] = null;
  52.  
  53.         }
  54.  
  55.  
  56.     } catch
  57.     (PDOException $e) {
  58.         echo "Falhou: " . $e->getMessage();
  59.     };
  60.  
  61. };
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top