Advertisement
Guest User

Untitled

a guest
Oct 2nd, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. <?php
  2. if(isset($_POST['submit'])) {
  3. mysql_connect("localhost", "root", "pass");
  4. mysql_select_db("database");
  5.  
  6. $username = $_POST['username'];
  7. $password = $_POST['password'];
  8.  
  9. $username = mysql_real_escape_string($username);
  10. $password = mysql_real_escape_string($password);
  11.  
  12. $password = md5($password);
  13.  
  14. $sql = mysql_query("SELECT * FROM users WHERE username = '$username' AND password = '$password'");
  15. $nr = mysql_num_rows($sql);
  16.  
  17. if($nr == 0) {
  18. echo "Bad login, try again";
  19. }else{
  20. while($row = mysql_fetch_array($sql)) {
  21. $username = $row['username'];
  22. }
  23. session_start();
  24. $_SESSION['lia'] = $username;
  25. echo "Welcome, ".$_SESSION['lia']."";
  26. echo "<a href='home.php'>Home page</a>";
  27. header('Location: home.php');
  28. }
  29. }
  30. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement