Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- include 'connection.php';
- $error='';
- // array for JSON response
- $response = array();
- if (isset($_POST['nim']) && isset($_POST['password'])){
- if (empty($_POST['nim']) || empty($_POST['password'])) {
- // required field is missing
- $response["success"] = 0;
- $response["message"] = "Data Tidak Lengkap";
- // echoing JSON response
- echo json_encode($response);
- }else{
- $nim=$_POST['nim'];
- $password=$_POST['password'];
- $query = "select * from user where password='$password' AND nim='$nim'";
- $sql = mysqli_query($con, $query);
- $rows = mysqli_fetch_array($sql);
- if ($rows) {
- // required field is missing
- $response["success"] = 1;
- $response["message"] = "Berhasil Login";
- // echoing JSON response
- echo json_encode($response);
- } else {
- // required field is missing
- $response["success"] = 0;
- $response["message"] = "Username atau Password Salah";
- // echoing JSON response
- echo json_encode($response);
- }
- }
- }else {
- // required post params is missing
- $response["success"] = 0;
- $response["message"] = "Kesalahan pada data anda";
- echo json_encode($response);
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement