Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="utf-8">
- <title>Welcome</title>
- <style>
- h1, h2, h3{
- color: coral;
- text-align: center;
- }
- </style>
- </head>
- <body>
- <?php
- //read user inputs from login form
- $name=$_POST["name"];
- echo "<h1>Welcome $name</h1>";
- $password=$_POST["password"];
- //declare database variables
- $dbserver="localhost:3307";
- $dbuser="root";
- $dbpassword="";
- $dbname="sbdb2019";
- //create connection
- $conn = new mysqli($dbserver,$dbuser,$dbpassword,$dbname);
- //check connection successful
- if($conn->connect_error==true){
- echo "connection failed".$conn->connect_error;
- }else{
- echo "<h2>Connection Successful</h2>";
- }
- //create sql to check user and password
- $sql="SELECT * FROM CUSTOMER WHERE name='".$name."' and password='".$password."'";
- //execute sql and assign to result
- $result = $conn->query($sql);
- //check whether result has any rows
- if($result->num_rows>0){
- }else{
- die("<h3>You are not authorised to access this information</h3>");
- }
- ?>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement