Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // i tried echoing everything possible but no outcome
- <?php
- include("conn.php");
- if(isset($_POST['btn_login'])){
- $username = $_POST['username'];
- $password = $_POST['password'];
- }
- $sql = "SELECT * FROM users WHERE username='$username' AND password='$password' LIMIT 1";
- $result = mysqli_query($conn,$sql);
- $response = array();
- if(mysqli_num_rows($result)>0){
- $row = mysqli_fetch_row($result);
- $username = $row['username'];
- $password = $row['password'];
- $code = "login_success";
- array_push($response,array("code"=>$code,"username"=>$username,"password"=>$password));
- echo json_encode($response);
- }
- else{
- $code = "login_failed";
- $message = "User not found... Please try again";
- array_push($response, array("code"=>$code,"message"=>$message));
- echo json_encode($response);
- }
- mysqli_close($conn);
- ?>
- <!DOCTYPE html>
- <html>
- <head>
- <title></title>
- </head>
- <body>
- <form method="post">
- <input type="text" name="username">
- <input type="text" name="password">
- <input type="submit" name="btn_login">
- </form>
- </body>
- </html>
Add Comment
Please, Sign In to add comment