Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $servername="localhost";
- $username="root";
- $password="";
- $conn = new mysqli($servername,$username,$password) or die ("Cant connect to database");
- mysqli_select_db($conn,"db_login");
- if(mysqli_connect_errno()){
- echo 'failed to connect to database<br>';
- }
- else{
- echo "connected<br>";
- }
- if(isset($_POST['login'])){
- $user=$_POST['username'];
- $pass=$_POST["password"];
- $query="SELECT * FROM 'admin' WHERE username='$user' and password='$pass'";
- if($result=mysqli_query($conn,$query)){
- $rowcount = mysql_num_rows($result);
- if(rowcount>=1){
- header('location:index.php');
- }
- else{
- echo "login failed";
- }
- }
- }
- ?>
- <!DOCTYPE html>
- <html>
- <head>
- <title> Login </title>
- </head>
- <form method="post">
- <body>
- <input type="text" name="username" placeholder="username"><br>
- <input type="password" name="password" placeholder="password"><br>
- <input type="submit" name="login">
- </body>
- </form>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement