Advertisement
Guest User

Untitled

a guest
May 23rd, 2012
498
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.79 KB | None | 0 0
  1. <form id="login" action="process_login.php" type="POST" >
  2. Username: <input type="text" id="username" />
  3. Password: <input type="password" id="password" />
  4. <input type="Submit" value="Login" />
  5. </form>
  6.  
  7. In process_login.ph file...
  8.  
  9. $uname = $_POST['username']; // ID of username field in form will be username
  10. $pswd = $_POST['password'];  // ID of password field in form will be password
  11.  
  12. $sql  = "SELECT username from users where username='$uname' AND password ='$pswd'"; // make sure the column names match the fields in your database
  13.  
  14. $result = mysql_query($sql);
  15. $row = mysql_fetch_row($result); // will return number of match rows
  16.  
  17. if ($row) {
  18.     header("Location: /successful.html"); // redirect the user to whichever page
  19.   } else {
  20.     header("Location: /failed.html");
  21.   }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement