Guest User

Untitled

a guest
Sep 29th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.78 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html lang="en" dir="ltr">
  3.   <head>
  4.     <meta charset="utf-8">
  5.     <title></title>
  6.     <link rel="stylesheet" href="../css/bootstrap.min.css">
  7.   </head>
  8.   <body>
  9.     <?php
  10.  
  11.     if ((!empty($_POST['uname'])) && (!empty($_POST['pwd']))) {
  12.       // assign post values to variables
  13.       $user_mail = $_POST['uname'];
  14.       $user_pass = $_POST['pwd'];
  15.  
  16.       //connect to database
  17.       $link = mysqli_connect("localhost","root","","foo");
  18.  
  19.       if (!$link)
  20.       {
  21.         echo mysqli_connect_error();
  22.         exit();
  23.       }
  24.  
  25.       //check email exist in database
  26.       $result = mysqli_query($link, "SELECT email FROM register WHERE email='$user_mail'");
  27.       if (mysqli_num_rows($result) == 1) {
  28.  
  29.         //this line is optional - free memory related to result
  30.         mysqli_free_result($result);
  31.  
  32.         // if email is in database
  33.         $result = mysqli_query($link, "SELECT * FROM register WHERE email='$user_mail' AND password='$user_pass'");
  34.  
  35.         //check if user details match
  36.         if (mysqli_num_rows($result) == 1) {
  37.           $row =  mysqli_fetch_array($result,MYSQLI_ASSOC);
  38.           echo "<h1>User Details</h1>";
  39.           echo "<h3>Firstname : " . $row['firstname'] . "</h3>";
  40.           echo "<h3>Lastname : " . $row['lastname'] . "</h3>";
  41.           echo "<h3>Mobile : " . $row['mobile'] . "</h3>";
  42.           echo "<h3>Address : " . $row['address'] . "</h3>";
  43.           echo "<h3>E-Mail : " . $row['email'] . "</h3>";
  44.           mysqli_free_result($result);
  45.  
  46.         } else {
  47.           echo "Password is wrong";
  48.         }
  49.       } else {
  50.         echo "User is not registered!";
  51.       }
  52.  
  53.       // close connection
  54.       mysqli_close($link);
  55.  
  56.     } else {
  57.       echo "Details are missing!";
  58.     }
  59.  
  60.     ?>
  61.   </body>
  62. </html>
Advertisement
Add Comment
Please, Sign In to add comment