daily pastebin goal
59%
SHARE
TWEET

Untitled

a guest Jun 8th, 2017 122 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.     $invaliduser = false;
  3.     $invalidpass = false;
  4.     $dupuser = false;
  5.     $success=false;
  6.     if($_SERVER['REQUEST_METHOD'] == 'POST') {
  7.         if (!empty($_POST["username"]) && !empty($_POST["password"])) {
  8.             $reg1 = '/^(([^<>()[\]\\\\.,;:\s@\"]+(\.[^<>()[\]\\\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/';
  9.             $reg2 = '/^(?:[0-9]+[a-zA-Z]|[a-zA-Z]+[0-9])[A-Za-z0-9]*$/';
  10.             include("database.php");
  11.             $user = mysqli_real_escape_string($conn, $_POST["username"]);
  12.             $pass = mysqli_real_escape_string($conn, $_POST["password"]);
  13.             $invaliduser = !preg_match($reg1, $user);
  14.             $invalidpass = !preg_match($reg2, $pass);
  15.             if (!$invaliduser && !$invalidpass) {
  16.                 $pass=md5($pass);
  17.                 $result = mysqli_query($conn, "INSERT INTO `user`(`username`, `password`) VALUES (\"" . $user . "\",\"" . $pass . "\")");
  18.                 if ($result) {
  19.                     $dupuser = false;
  20.                     $success = true;
  21.                 } else {
  22.                     if (mysqli_errno($conn) == 1062) {//duplicate user
  23.                         $dupuser = true;
  24.                     } else {
  25.                         die("Errore generale nel database!");
  26.                     }
  27.                 }
  28.             }
  29.         }
  30.     }
  31. ?>
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
 
Top