Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if(isset($_POST['submit'])) {
- mysql_connect("localhost", "root", "pass");
- mysql_select_db("database");
- $username = $_POST['username'];
- $password = $_POST['password'];
- $username = mysql_real_escape_string($username);
- $password = mysql_real_escape_string($password);
- $password = md5($password);
- $sql = mysql_query("SELECT * FROM users WHERE username = '$username' AND password = '$password'");
- $nr = mysql_num_rows($sql);
- if($nr == 0) {
- echo "Bad login, try again";
- }else{
- while($row = mysql_fetch_array($sql)) {
- $username = $row['username'];
- }
- session_start();
- $_SESSION['lia'] = $username;
- echo "Welcome, ".$_SESSION['lia']."";
- echo "<a href='home.php'>Home page</a>";
- header('Location: home.php');
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement