Advertisement
Guest User

Untitled

a guest
Mar 30th, 2015
216
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.61 KB | None | 0 0
  1. <?php
  2.  
  3. $host="xxxxx"; // Host name
  4. $username="xxxxx"; // Mysql username
  5. $password="xxxxx"; // Mysql password
  6. $db_name="xxxxx"; // Database name
  7. $tbl_name="userDetails"; // Table name
  8.  
  9. // Connect to server and select databse.
  10. mysql_connect("$host", "$username", "$password")or die("cannot connect");
  11. mysql_select_db("$db_name")or die("cannot select DB");
  12.  
  13. // username and password sent from form
  14. $Username=$_POST['Username'];
  15. $Password=$_POST['Password'];
  16.  
  17.  
  18. $Username = stripslashes($Username);
  19. $Password = stripslashes($Password);
  20. $Username = mysql_real_escape_string($Username);
  21. $Password = mysql_real_escape_string($Password);
  22. $query="SELECT * FROM $tbl_name WHERE Username='$Username' AND Password='$Password'";
  23. $result=mysql_query($query);
  24. //$row = mysql_fetch_array($result);
  25. //=mysql_query($sql);
  26.  
  27. // Mysql_num_row is counting table row
  28. //$count=mysql_num_rows($result);
  29.  
  30. // If result matched $Username and $Password, table row must be 1 row
  31. //if ( $row['Username'] == $Username && $row['Password'] == $Password )
  32. if ($result)
  33. {
  34. // Register $Username, $Password and redirect to file "success.php"
  35. session_register("Username");
  36. session_register("Password");
  37. session_start();
  38. $_SESSION['login_user']= $Username; // Initializing Session with value of PHP Variable
  39. echo $_SESSION['login_user'];
  40. echo "you are now logged in";
  41. header("Refresh:0; url=index.html");
  42. //header("location:success.php");
  43. }
  44.  
  45. else {
  46. echo "Wrong Username or Password";
  47.  
  48. }
  49.  
  50. ob_end_flush();
  51. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement