Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $server="localhost";
- $username="root";
- $password="admin007#";
- $dbname="demo";
- $con=new mysqli($server,$username,$password,$dbname);
- if(!$con)
- {
- die('error connecting to the database');
- }
- if(isset($_POST['login'])){
- $a=mysqli_real_escape_string($con, $_POST['user']);
- $b=mysqli_real_escape_string($con, $_POST['pass']);
- $sql="SELECT * FROM login WHERE username='$a' AND password='$b'";
- $result=mysqli_query($con, $sql);
- $check=mysqli_num_rows($result);
- if($check>0){
- echo "you are logged in";
- }
- else
- {
- echo "Error";
- }
- }
- ?>
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- <title>Untitled Document</title>
- </head>
- <body>
- <tr>
- <td>Username:</td>
- <td><input type="text" name="user" value=""/></td>
- </tr><br /><br />
- <tr>
- Password:
- <td><input type="password" name="pass" value=""/></td>
- </tr><br />
- <tr align="center"><td colspan="2"><input type="submit" name="login" value="Log In"/></td></tr>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement