Guest User

Untitled

a guest
Oct 17th, 2017
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.10 KB | None | 0 0
  1. <?php
  2. // Make your access codes as constants
  3. define("DBHOST", "localhost");
  4. define("DBUSER", "root");
  5. define("DBPWD", "2468");
  6. define("DBNAME", "information");
  7.  
  8. $myusername = $_POST['username'];
  9. $mypassword = $_POST['password'];
  10. $tablename = "members";
  11. $link = dbconnect();
  12. $sql = "SELECT * FROM `" . $tablename . "` WHERE `username` = '" . $myusername ."' and `password` = '" . $mypassword . "' ";
  13. // note the syntax!!!
  14.  
  15.  
  16. function dbconnect()
  17. {
  18.     $link = mysql_connect(DBHOST, DBUSER, DBPWD) or die (mysql_error("Error "));
  19.     mysql_select_db(DBNAME) or die(mysql_error("Could not select database"));
  20.     return($link);
  21. }
  22.  
  23. $result = mysql_query($sql);
  24. $row = mysql_fetch_array($result);
  25.  
  26. // you dont need to free result or mysql_connect as of the newer version of php these are done automatically
  27.  
  28. if ($row['username'] == "")
  29. {
  30.      header("location:fail.php");
  31. }
  32. else{
  33.     header("location:success.php");
  34. }
  35. ?>
  36.  
  37. <head>
  38.  
  39. </head>
  40.  
  41. <body>
  42. <form method="post">
  43.  
  44. <input name="password" type="text" />
  45. <input name="password" type="text" />
  46. <input type="submit" value="Login" />
  47.  
  48. </form>
  49. </body>
Add Comment
Please, Sign In to add comment