PHP Login


SUBMITTED BY: Guest

DATE: May 19, 2013, 3:51 a.m.

FORMAT: PHP

SIZE: 1.4 kB

HITS: 2015

  1. // Better version of
  2. http://pastebin.com/ut1Sh2sF
  3. <?php
  4. include ("./inc/template/header-index.php");
  5. if(isset($_SESSION['username']))
  6. {
  7. header("Location: cpu.php");
  8. }
  9. $d =(isset($_GET['do']) && $_GET['do'] == 'check');
  10. {
  11. if(isset($_POST['username']) && isset($_POST['password']))
  12. {
  13. $uName = mysql_real_escape_string($_POST['username']);
  14. $pWord = mysql_real_escape_string(md5($_POST['password']));
  15. $aSQL = mysql_query("SELECT * FROM users WHERE username = '".$username."' AND password = '".$password."'") or die(mysql_error());
  16. if(!mysql_num_rows($aSQL))
  17. {
  18. $error = "Enter you username and password to log in";
  19. }else{
  20. $_SESSION['username'] = true;
  21. $_SESSION['password'] = $password;
  22. header("Location: cpu.php");
  23. }
  24. }
  25. ?>
  26. <?php if(isset($error)) { echo "".$error.""; } ?>
  27. <form action="/index.php?do=check" method="post">
  28. <input type="text" name="username" placeholder="Username" /><br>
  29. <input type="password" name="password" placeholder="Password" /><br>
  30. <input type="submit" name="login" value="Login" />
  31. </form>

comments powered by Disqus