Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- include("connection.php");
- header('Content-Type: application/json');
- if (isset($_POST['username']) && isset($_POST['password']))
- {
- $username=$_POST['username'];
- $password=sha1($_POST['password']);
- $_SESSION['login_user']=$username;
- //session_start();
- $response_array=[];
- $sql = "SELECT ID,Username,Password,role FROM intern1 WHERE Username='$username' and Password='$password'";
- $query = mysqli_query($conn,$sql);
- // echo $sql;
- // $_SESSION['role']=$row['role'];
- $field = mysqli_fetch_array($query);
- $_SESSION['user_id']=$field['ID'];
- $count=mysqli_num_rows($query);
- if ($count == 1)
- {
- if ($field['role']==1)
- {
- $response_array['status']="admin";
- }
- else if ($field['role']==2)
- {
- $response_array['status']="super";
- }
- else
- {
- $response_array['status']="normal";
- }
- }
- else
- {
- $response_array['status']="invalid";
- }
- echo json_encode($response_array);
- }
- ?>
- //login.js
- $('#submit').click(function() {
- var username = $('#uname').val();
- var password = $('#pass').val();
- $('#dummy').empty();
- $.ajax({
- type: 'POST',
- url: 'login.php',
- data: {
- username: username,
- password: password
- },
Add Comment
Please, Sign In to add comment