Advertisement
lowheartrate

Untitled

Jun 5th, 2015
354
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.47 KB | None | 0 0
  1. <h1>Register</h1>
  2.  
  3. <form method="POST">
  4.     <input style="margin-bottom: 5px;" type="text" name="username" placeholder="Username" required><br />
  5.     <input style="margin-bottom: 5px;" type="password" name="password" placeholder="Password" required><br />
  6.     <input style="margin-bottom: 5px;" type="password" name="cpassword" placeholder="Confirm Password" required><br />
  7.     <input style="margin-bottom: 10px;" type="email" name="email" placeholder="Email Address" required><br />
  8.     <input style="width: 175px;" type="submit">
  9. </form>
  10.  
  11. <?php
  12. session_start();
  13.  
  14.     if(isset($_POST['username'], $_POST['password'], $_POST['cpassword'], $_POST['email'])){
  15.         require 'core/connect.php';
  16.  
  17.         error_reporting(0);
  18.  
  19.         $username = $_POST['username'];
  20.         $password = $_POST['password'];
  21.         $cpassword = $_POST['cpassword'];
  22.         $email = $_POST['email'];
  23.  
  24.         $query = dbConnect()->prepare("INSERT INTO users (username, password, cpassword, email) VALUES (:username, :password, :cpassword, :email)");
  25.         $query->bindParam(':username', $_POST['username']);
  26.         $query->bindParam(':password', md5($_POST['password']));
  27.         $query->bindParam(':cpassword', md5($_POST['cpassword']));
  28.         $query->bindParam(':email', $_POST['email']);
  29.  
  30.         if(strlen($username)<6) {
  31.             echo "Username must be at least 6 characters";
  32.         } else {
  33.             $query->execute();
  34.             header("Location: index.php");
  35.         }
  36.     }
  37. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement