Advertisement
Guest User

Untitled

a guest
May 20th, 2016
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.31 KB | None | 0 0
  1. <?php
  2. session_start();
  3. header('Content-type: application/json');
  4. if(!isset($_POST['emailorusername'],$_POST['password'])) {
  5. $result = array("result" => "404", "reason" => "Tai!");
  6. } else {
  7. include('database.php');
  8. function anti($str) {
  9. return stripslashes(strip_tags(htmlspecialchars($str,ENT_QUOTES)));
  10. }
  11. $emailorusername = $con->real_escape_string($_POST['emailorusername']);
  12. $password = md5($con->real_escape_string($_POST['password']));
  13. if (empty($emailorusername) && empty($password)) {
  14. $result = array("result" => "404", "reason" => "E-Mail / Username & Password tidak boleh kosong!");
  15. } elseif (empty($emailorusername)) {
  16. $result = array("result" => "404", "reason" => "E-Mail / Username tidak boleh kosong!");
  17. } elseif (empty($password)) {
  18. $result = array("result" => "404", "reason" => "Password tidak boleh kosong!");
  19. } else {
  20. $mysqli = $con->query("SELECT * FROM account WHERE (username='$emailorusername' OR email ='$emailorusername') AND password='$password'");
  21. $data = $mysqli->fetch_array;
  22. if($mysqli->num_rows == 1) {
  23. $_SESSION['login'] = $emailorusername.'|'.$password;
  24. $result = array("result" => "200", "reason" => "success");
  25. } else {
  26. $result = array("result" => "404", "reason" => "E-Mail / Username & Password yang ada masukkan belum terdaftar!");
  27. }
  28. }
  29. }
  30. print_r(json_encode($result));
  31. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement