Advertisement
Guest User

PHP Code

a guest
Mar 26th, 2012
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.99 KB | None | 0 0
  1. <?php
  2. ob_start();
  3. $host="mysql5.000webhost.com"; // Host name
  4. $sqlusername="X"; // Mysql username
  5. $sqlpassword="X"; // Mysql password
  6. $db_name="X"; // Database name
  7. $tbl_name="X"; // Table name
  8.  
  9. // Connect to server and select databse.
  10. mysql_connect("$host", "$sqlusername", "$sqlpassword")or die("cannot connect");
  11. mysql_select_db("$db_name")or die("cannot select DB");
  12.  
  13. // Define $username and $password
  14. $username=$_POST['username'];
  15. $password=$_POST['password'];
  16.  
  17. $sql="SELECT * FROM $tbl_name WHERE username='$username' and password='$password'";
  18. $result=mysql_query($sql);
  19.  
  20.  
  21. // Mysql_num_row is counting table row
  22. $count=mysql_num_rows($result);
  23. // If result matched $myusername and $password, table row must be 1 row
  24.  
  25. if($count==1){
  26. // Register $myusername, $password and redirect to file "login_success.php"
  27. session_register("username");
  28. session_register("password");
  29. header("location:home.php");
  30. }
  31. else {
  32. echo "Wrong Username or Password";
  33. }
  34.  
  35. ob_end_flush();
  36. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement