Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- lib/connection.php
- <?php
- mysql_connect("localhost","root","") or die(mysql_error());
- mysql_select_db("test_db") or die(mysql_error());
- ?>
- index.php
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <title>Login</title>
- <link rel="stylesheet" href="css/style.css">
- </head>
- <?php
- include 'lib/connection.php';
- if (isset($_POST['login'])) {
- @$query = mysql_query("SELECT * FROM user_tb WHERE username='$_POST[username]' AND password='$_POST[password]'");
- @$cek=mysql_num_rows($query);
- if ($cek>0) {
- @$o=mysql_fetch_array($query);
- echo "Login success";
- }else{
- echo "Failed";
- }
- }
- ?>
- <body>
- <form method="post">
- <h4 align="center">Please don't let them blank</h4>
- <table align="center">
- <tr>
- <td>Username</td>
- <td>:</td>
- <td><input type="text" name="username" autofocus></td>
- </tr>
- <tr>
- <td>Password</td>
- <td>:</td>
- <td><input type="text" name="password"></td>
- </tr>
- <tr>
- <td></td>
- <td></td>
- <td><input type="submit" name="login" value="LOGIN"></td>
- <?php echo mysql_error() ?>
- </tr>
- </table>
- </form>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement