Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function cek(){
- var username = $("#username").val();
- var password = $("#password").val();
- if (username == "" && password == "") {
- alert("Username and password can't be empty!");
- }else {
- $.ajax({
- url: "processLogin.php",
- type: "POST",
- data:{
- username: $("#username").val(), password: $("#password").val()
- },
- success:function(e){
- alert("e");
- }
- });
- }
- }
- $username = $_POST['username'];
- $password = $_POST['password'];
- $sql = "SELECT * FROM user WHERE nama='$username' AND password='$password'";
- $query = $db->query($sql)or die(mysqli_error($db));
- $result = $query->fetch_assoc();
- if ($query->num_rows == 0) {
- // I want this to be show on alert
- echo "Username not found!";
- }else{
- if ($password <> $result['password']) {
- // I want this to be show on alert
- echo "Incorrect password!";
- }else{
- $_SESSION['username'] = $result['nama'];
- $_SESSION['tipe'] = $result['tipe'];
- header('location:index.php');
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement