Guest User

Untitled

a guest
Jan 5th, 2018
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. <?php
  2. $host="localhost";
  3. $username="root";
  4. $pass="";
  5. $db_name="makanmulu";
  6. $tbl_name="user";
  7.  
  8. //connect to server and select database
  9. mysql_connect("$host","$username","$pass")or die("cannot connect");
  10. mysql_select_db("$db_name")or die("cannot select DB");
  11.  
  12. //username,password dan email sent from form
  13. $email=$_POST['email'];
  14. $password=$_POST['password'];
  15.  
  16. $sql="SELECT * FROM $tbl_name WHERE email='$email' and password='$password'";
  17. $result=mysql_query($sql);
  18.  
  19. $count=mysql_num_rows($result);
  20.  
  21. if($count==1)
  22. {
  23. setcookie('data', json_encode(mysql_fetch_assoc($result)) );
  24. header("location:home.php");
  25. }
  26. else
  27. {
  28. echo "Wrong Email or Password";
  29. }
  30. ?>
Add Comment
Please, Sign In to add comment