<?php session_start(); include "dbconnection.php"; $email = clean($_REQUEST['user_email']); $password = clean(md5($_REQUEST['password'])); $result = Userlogin($email, $password); $row = mysql_fetch_array($result); $loginuser = $row['email']; $loginpassword = $row['password']; $fullname = $row['firstname'] . " " . $row['lastname']; $userId = $row['user_id']; if ($loginuser == $email and $loginpassword == $password) { $_SESSION['email'] = $loginuser; $_SESSION['loged_password'] = $loginpassword; $_SESSION['loged_fullname'] = $fullname; $_SESSION['user_loged_id'] = $userId; header("location:index.php"); } else { header("location:register-user.php?msg"); } /* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */
<?php session_start(); header("Content-Type: application/json"); include "../dbconnection.php"; $user_name = mysql_real_escape_string($_POST['user_name']); $password = mysql_real_escape_string(md5($_POST['password'])); $result = Userlogin($user_name, $password); $user = mysql_fetch_array($result); if ($user['email'] == $user_name and $user['password'] == $password) { $user_data = array('user_id' => $user['user_id'], 'name' => $user['name'], 'email' => $user['email'], 'mobile_number' => $user['mobile_number'], 'gender' => $user['gender'], 'status' => '1'); echo json_encode($user_data); } else { if ($user['user_name'] == $user_name and $user['password'] == $password) { $user_data = array('user_id' => $user['user_id'], 'name' => $user['name'], 'email' => $user['email'], 'mobile_number' => $user['mobile_number'], 'gender' => $user['gender'], 'status' => '1'); echo json_encode($user_data); } else { $status = array('status' => 0, 'error' => 'Invalid User name or password'); echo json_encode($status); } }