Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- session_start();
- header('Content-type: application/json');
- if(!isset($_POST['emailorusername'],$_POST['password'])) {
- $result = array("result" => "404", "reason" => "Tai!");
- } else {
- include('database.php');
- function anti($str) {
- return stripslashes(strip_tags(htmlspecialchars($str,ENT_QUOTES)));
- }
- $emailorusername = $con->real_escape_string($_POST['emailorusername']);
- $password = md5($con->real_escape_string($_POST['password']));
- if (empty($emailorusername) && empty($password)) {
- $result = array("result" => "404", "reason" => "E-Mail / Username & Password tidak boleh kosong!");
- } elseif (empty($emailorusername)) {
- $result = array("result" => "404", "reason" => "E-Mail / Username tidak boleh kosong!");
- } elseif (empty($password)) {
- $result = array("result" => "404", "reason" => "Password tidak boleh kosong!");
- } else {
- $mysqli = $con->query("SELECT * FROM account WHERE (username='$emailorusername' OR email ='$emailorusername') AND password='$password'");
- $data = $mysqli->fetch_array;
- if($mysqli->num_rows == 1) {
- $_SESSION['login'] = $emailorusername.'|'.$password;
- $result = array("result" => "200", "reason" => "success");
- } else {
- $result = array("result" => "404", "reason" => "E-Mail / Username & Password yang ada masukkan belum terdaftar!");
- }
- }
- }
- print_r(json_encode($result));
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement