Advertisement
Guest User

Model

a guest
Oct 19th, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.15 KB | None | 0 0
  1. <?php
  2. include_once 'Connect.php';
  3. function reg($obj){
  4.     global $con;
  5.     $newsub = json_decode($obj);
  6.     $username = $newsub ->username;
  7.     $enc_pass = $newsub->pass;
  8.     $email = $newsub ->email;
  9.     $Fname = $newsub ->fname;
  10.     $Lname = $newsub->lname;
  11.    
  12.     $query2 = $con->prepare("
  13.                     SELECT *
  14.                     FROM user
  15.                     WHERE username = :username");
  16.                 $query2->bindParam(':username', $username);
  17.                 $query2->execute();
  18.                 $query = $con->prepare("INSERT INTO user (Fname, Lname, Email, Username, Password) VALUES(:fname, :lname, :email, :username, :password)");
  19.                 $query->bindParam(':fname', $Fname);
  20.                 $query->bindParam(':lname', $Lname);
  21.                 $query->bindParam(':email', $email);
  22.                 $query->bindParam(':username', $username);
  23.                 $query->bindParam(':password', $enc_pass);
  24.                 echo $Fname;
  25.                 echo $Lname;
  26.                 echo $Email;
  27.                 echo $username;
  28.                 echo $enc_pass;
  29.                
  30.             if($query2->rowCount() > 0){
  31.                 echo "<h1>username already exists please try diffrent log on</h1>";
  32.                
  33.            
  34.             }
  35.             else{
  36.                 $query->execute();
  37.                
  38.                
  39.                     header("Location: https://mayar.abertay.ac.uk/~1800854/WebDevTest/View/signin.php");
  40.                     die();
  41.             }
  42. }
  43. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement