daily pastebin goal
5%
SHARE
TWEET

Untitled

a guest Jun 29th, 2018 112 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. session_start();
  3. $host="localhost"; // Host name
  4. $username="root"; // Mysql username
  5. $password=""; // Mysql password
  6. $db_name="assignment"; // Database name
  7.  
  8.  
  9. // Connect to server and select databse.
  10. mysql_connect("$host", "$username", "$password","$db_name")or die("cannot connect");
  11. mysql_select_db("$db_name")or die("cannot select DB");
  12.  
  13. // Define $myusername and $mypassword
  14. $myusername=$_POST['myusername'];
  15. $mypassword=$_POST['mypassword'];
  16.  
  17.  
  18.  
  19. $sql="SELECT * FROM Member WHERE UserName='$myusername' AND Password='$mypassword'";
  20. $result = mysql_query($sql);
  21.  
  22.  
  23.  
  24.  
  25. // Mysql_num_row is counting table row
  26. $count = mysql_num_rows($result);
  27. // If result matched $myusername and $mypassword, table row must be 1 row
  28.  
  29.  
  30. if($count == 1){
  31. $_SESSION['myusername'] = $_POST['myusername'];
  32. $_SESSION['mypassword'] = $_POST['mypassword'];
  33.  header( 'Location:LoginSucess.php' ) ;
  34.  
  35. }
  36. else if($_REQUEST['myusername'] == "admin" && $_REQUEST['mypassword'] == "admin123") {
  37.     session_register("myusername");
  38.     session_register("mypassword");
  39.  header( 'Location:admin.php' ) ;
  40. }
  41.  
  42. echo "Wrong Username or Password";
  43. echo "<br/><input type=button value='Back' onclick='javascript:history.go(-1);'>";
  44.  
  45.  
  46. ?>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top