Advertisement
phirani

Login page coding

Dec 19th, 2014
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. <?php
  2. session_start();
  3. session_regenerate_id(true);
  4. $username = $_POST['username'];
  5. $password = $_POST['password'];
  6. $login = $_SERVER['HTTP_REFERER'];
  7. $_SESSION["username"] = "$username";
  8.  
  9. if( ( !$username) or (! $password ))
  10. {header ("Location:$login"); exit(); }
  11.  
  12. $conn=@mysql_connect( "localhost", "root", "")
  13. or die ("cannot connect");
  14.  
  15. $rs = @mysql_select_db("dbusers", $conn)
  16. or die("database problem");
  17.  
  18. $sql = "select * from dropbox where uname=\"$username\" and pass = \"$password\"";
  19.  
  20. $rs = mysql_query($sql, $conn)
  21. or die ("could not execute query");
  22.  
  23. $rows = mysql_numrows( $rs);
  24.  
  25. if($rows !=0)
  26. {
  27. echo("<h2>$username okay - !welcome!</h2>");
  28.  
  29. }
  30. else
  31. {
  32. header("Location:$login"); exit();
  33. }
  34.  
  35.  
  36.  
  37. ?>
  38. <html>
  39.  
  40. <body>
  41. Session usr =
  42. <?php
  43. echo(session_id());
  44. ?>
  45. <br><br>
  46.  
  47. <a href="home.php?<?php echo(SID); ?>">Go to next page</a>
  48.  
  49. <a href="home.php">Home</a>
  50.  
  51. </body>
  52.  
  53. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement