Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static function login()
- {
- // header("Content-Type: application/json");
- // header("Content-Type: text/javascript");
- $response->msg = '';
- $username = $_POST['username'];
- $password = $_POST['password'];
- $hashed = hash('md5', $password);
- $query = mysql_query("select * from tbl_user where username = '$username' and password = '$hashed'");
- $result = mysql_fetch_object($query);
- if(mysql_num_rows($result) > 0)
- {
- $response->msg = 1;
- $response->username = $username;
- // $response['msg'] = 1;
- // $response['username'] = $username;
- echo json_encode($response);
- }
- else
- {
- // $response['msg'] = 0;
- $response->msg = 0;
- echo json_encode($username);
- }
- }
- $("#btn_submit").click(function(){
- var username = $("#txtusername").val();
- var password = $("#mypassword").val();
- $.ajax({
- url: base_url + 'includes/main.php/login',
- data: { username: username, password: password },
- type: 'post',
- // async:false,
- dataType: 'json',
- success: function(data)
- {
- console.log(data);
- }
- });
- });
- // $('#btn_submit').click(function() {
- // var username = $("#txtusername").val();
- // var password = $("#mypassword").val();
- //
- // $.getJSON(base_url + 'includes/main.php/login',
- // { username: username, password: password },
- // function(json) {
- // console.log(json);
- // });
- // });
- // $('#btn_submit').click(function() {
- // var username = $("#txtusername").val();
- // var password = $("#mypassword").val();
- //
- // $.post(base_url + 'includes/main.php/login',
- // {username: username, password: password},
- // function(r) {
- // console.log(r);
- // }, "json");
- // });
- url: base_url + 'includes/main.php/login',
- $("#btn_submit").click(function(){
- var username = $("#txtusername").val();
- var password = $("#mypassword").val();
- $.ajax({
- url: base_url + 'includes/main.php',
- data: { action:'login', username: username, password: password },
- type: 'post',
- dataType: 'json',
- success: function(data)
- {
- console.log(data);
- }
- });
- return false;
- });
- if(isset($_POST['action']) && $_POST['action'] == 'login') {
- login();
- }
- function login()
- {
- header("Content-Type: application/json");
- $response->msg = '';
- $username = $_POST['username'];
- $password = $_POST['password'];
- // Do the rest ............
- }
- $.ajax({
- url: base_url + 'includes/main.php/login',
- data: { username: username, password: password },
- // async:false,
- type: 'post',
- dataType: 'json',
- success: function(data)
- {
- console.log(data);
- }
- });
- $query = mysql_query("select * from tbl_user where username = $username and password = $hashed");
- $query = mysql_query("select * from tbl_user where username = '$username' and password = '$hashed'");
- $query = mysql_query("select * from tbl_user where username = $username and password = $hashed") or die('Query error');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement