Advertisement
TheMadProf

php issues

Jul 13th, 2017
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.24 KB | None | 0 0
  1. <?php
  2. $host_name = "db690172471.db.1and1.com";
  3. $database = "db690172471";
  4. $user_name = "dbo690172471";
  5. $password = "JrJsmpXH5SM24Z4R";
  6.  
  7. $connect = mysqli_connect($host_name, $user_name, $password, $database);
  8.  
  9. if ($connect) {
  10.     //  Stuff to do when connected to DB
  11.    
  12.     //  Retrieves the username value from post
  13.     $username=$_POST["email"];
  14.     $pwh=$_POST["pwh"];
  15.    
  16.     //  Checks to see if the username exists...
  17.     $sql="SELECT email FROM Users WHERE email='$username'";
  18.     $sql=mysqli_real_escape_string($connect, $sql);
  19.    
  20.     $query = mysqli_query($connect,$sql);
  21.    
  22.     if (mysqli_num_rows($query) != 0) {
  23.         //  User already exists so check pw and set session varb to logged in
  24.         echo "user exists";
  25.        
  26.     } else {
  27.         //  Need to create user.
  28.         echo "user $username does not exist";
  29.        
  30.         //  Adds the details to the db?
  31.         $sql="INSERT INTO Users (email, password) VALUES ('$username', '$pwh');";
  32.        
  33.         $sql=mysqli_real_escape_string($connect, $sql);
  34.        
  35.         $query2=mysqli_query($connect,$sql);
  36.        
  37.         if ($query2) {
  38.        
  39.             echo "New record created successfully";
  40.        
  41.         } else {
  42.        
  43.             //echo "Error: " . $sql . "<br>" . $connect->error;
  44.             echo "error"        ;
  45.         }
  46.        
  47.     }
  48. }
  49. else
  50. {
  51.     //  Stuff to do when not connected...
  52.     echo "problemo";
  53. }
  54.  
  55. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement