Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $localhost = "localhost";
- $username = "root";
- $password = "";
- $db = "login";
- $conn = mysql_connect($localhost, $username, $password);
- if(! $conn )
- {
- die('Could not connect: ' . mysql_error());
- }
- if($conn )
- {
- echo "Uspjesno spajanje na bazu! <br /><br />";
- }
- mysql_select_db($db);
- session_start();
- if(isset($_POST['submit']))
- {
- if(!empty($_POST['user']) && !empty($_POST['pass']))
- {
- $user=$_POST ['user'];
- $pass=$_POST ['pass'];
- $select="select * from users where username='$user' && password='$pass'";
- $sql=mysql_query($select) or die(mysql_error());
- if(mysql_num_rows($sql)==1 )
- {
- echo "Login";
- $_SESSION['user'] = $user;
- header('location: welcome.php');
- }
- else {
- echo "Can't Login";
- }
- }
- }
- if (isset($_GET['logout'])){
- session_unregister('username');
- }
- ?>
- <html>
- <head>
- </head>
- <body>
- <form method="post" action="login.php">
- Username: <input type="text" name="user" id="user" /> <br /> <br />
- Password: <input type="password" name="pass" id="pass" /> <br /> <br />
- <input type="submit" name="submit" value="Log In" />
- </body>
- </html>
Add Comment
Please, Sign In to add comment