Advertisement
Guest User

Untitled

a guest
Apr 18th, 2019
167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.32 KB | None | 0 0
  1. <?php
  2.  
  3. session_start();
  4.  
  5. if(isset($_POST['firstname']) && !empty($_POST['firstname']) AND isset($_POST['lastname']) && !empty($_POST['lastname']) AND isset($_POST['username']) && !empty($_POST['username']) AND isset($_POST['password']) && !empty($_POST['password']) AND isset($_POST['confirm_password']) && !empty($_POST['confirm_password']) AND isset($_POST['email']) && !empty($_POST['email']))
  6. {
  7.     $firstname = $_POST['firstname'];
  8.     $lastname = $_POST['lastname'];
  9.     $email = $_POST['email'];
  10.     $username = $_POST['username'];
  11.     $password = $_POST['password'];
  12.        
  13.     $ERROR = false;
  14.    
  15.    
  16.     if (!filter_var($email, FILTER_VALIDATE_EMAIL)){
  17.    
  18.     echo("The email you have entered is invalid, please try again.");
  19. }else{
  20.     if ($_POST["password"] == $_POST["confirm_password"])
  21.     {
  22.         $password = $_POST['password'];
  23.    
  24.         $db = mysqli_connect('localhost','root','','reg');
  25.    
  26.  
  27.         $query = "INSERT INTO user (firstname, lastname, username, password, email)
  28.               VALUES('$firstname','$lastname','$username'  ,'$password', '$email')";
  29.    
  30.         mysqli_query($db, $query);
  31.         $_SESSION['username'] = $username;
  32.         $_SESSION['success'] = "You have now registered";
  33.    
  34.         $ERROR = false;
  35.        
  36.         header('location: index.php');
  37.     }
  38.     else{
  39.             $ERROR = true;
  40.         }
  41.    
  42. }
  43.    
  44. }
  45. else{
  46.         echo("All Areas must be filled");
  47. }
  48.  
  49. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement