Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html lang="en" dir="ltr">
- <head>
- <meta charset="utf-8">
- <title></title>
- <link rel="stylesheet" href="../css/bootstrap.min.css">
- </head>
- <body>
- <?php
- if ((!empty($_POST['uname'])) && (!empty($_POST['pwd']))) {
- // assign post values to variables
- $user_mail = $_POST['uname'];
- $user_pass = $_POST['pwd'];
- //connect to database
- $link = mysqli_connect("localhost","root","","foo");
- if (!$link)
- {
- echo mysqli_connect_error();
- exit();
- }
- //check email exist in database
- $result = mysqli_query($link, "SELECT email FROM register WHERE email='$user_mail'");
- if (mysqli_num_rows($result) == 1) {
- //this line is optional - free memory related to result
- mysqli_free_result($result);
- // if email is in database
- $result = mysqli_query($link, "SELECT * FROM register WHERE email='$user_mail' AND password='$user_pass'");
- //check if user details match
- if (mysqli_num_rows($result) == 1) {
- $row = mysqli_fetch_array($result,MYSQLI_ASSOC);
- echo "<h1>User Details</h1>";
- echo "<h3>Firstname : " . $row['firstname'] . "</h3>";
- echo "<h3>Lastname : " . $row['lastname'] . "</h3>";
- echo "<h3>Mobile : " . $row['mobile'] . "</h3>";
- echo "<h3>Address : " . $row['address'] . "</h3>";
- echo "<h3>E-Mail : " . $row['email'] . "</h3>";
- mysqli_free_result($result);
- } else {
- echo "Password is wrong";
- }
- } else {
- echo "User is not registered!";
- }
- // close connection
- mysqli_close($link);
- } else {
- echo "Details are missing!";
- }
- ?>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment