noordean

register.php

Sep 29th, 2016
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.81 KB | None | 0 0
  1. <?php
  2. require_once('class.php');
  3. if (isset($_POST['submit'])){
  4.     if (empty($_POST['email']) || empty($_POST['username']) || empty($_POST['password1']) || empty($_POST['password'])){
  5.         echo "<p style='color:red'>Fill all required fields</p>";
  6.     }
  7.     elseif ($_POST['password1'] != $_POST['password']) {
  8.         echo "<p style='color:red'>Passwords do not match</p>";
  9.     }
  10.     else{
  11.         if (strpos($_POST['email'],'.')  < 1 or strpos($_POST['email'],'@') < 1){
  12.         echo "<p style='color:red'>Enter a valid email address</p>";
  13.         }
  14.         else{
  15.             $user = new User();
  16.             $email = $user->escapeInput($_POST['email']);
  17.             $username = $user->escapeInput($_POST['username']);
  18.             $password = sha1($user->escapeInput($_POST['password']));
  19.             if ($user->register($email,$username,$password)){
  20.                 header("Location:login_html.php");
  21.             }
  22.         }
  23.     }
  24. }
Add Comment
Please, Sign In to add comment