Advertisement
Ezequiel_Medina

Nuevo usuario alta

Sep 7th, 2018
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.11 KB | None | 0 0
  1. <?php
  2. include 'connection.php';
  3.  
  4. $mysqli->stmt_init();
  5.  
  6. $Username_Alta = $_POST['Username'];
  7. $Email = $_POST['Email'];
  8. $PIN = $_POST['PIN'];
  9. $pass = $_POST['Password'];
  10. $Password = password_hash($pass, PASSWORD_BCRYPT);
  11.  
  12. $stmt = $mysqli->prepare("SELECT * FROM Usuarios WHERE Email = ?");
  13. $stmt->bind_param('s', $Email);
  14.  
  15. if($result = $stmt->execute()){
  16.  
  17.     while ($row = $result->fetch_assoc()) {
  18.         $PIN_DB = $row['PIN'];
  19.     }
  20.  
  21.     if ($PIN == $PIN_DB) {
  22.         $stmt = $mysqli->prepare('UPDATE Usuarios SET Username=?, Password=? WHERE PIN=?;');
  23.         $stmt->bind_param('sss', $Username_Alta, $Password, $PIN);
  24.        
  25.         if ($stmt->execute()) {
  26.             $stmt = $mysqli->prepare('UPDATE Usuarios SET PIN="" WHERE Username=?;');
  27.             $stmt->bind_param('s', $Username_Alta);
  28.             $stmt->execute();
  29.             Header("Location: https://".$_SERVER["SERVER_NAME"]."/cliente?Confirmar_Alta&Alta_Ok");
  30.         }else{
  31.             Header("Location: https://".$_SERVER["SERVER_NAME"]."/cliente?Confirmar_Alta&Alta_Error");
  32.         }
  33.     }
  34. } else {
  35.     Header("Location: https://".$_SERVER["SERVER_NAME"]."/cliente?Confirmar_Alta&DB_Error");
  36. }
  37.  
  38. mysqli_close($mysqli);
  39. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement