Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $username = trim($_POST['username']);
- $password = trim($_POST['password']);
- if (isset($username) AND isset($password)) {
- $db = new DBOperations();
- if($db->userLogin($username, $password)) {
- $user = $db->getUsernameByUsername($username);
- $response['error'] = false;
- $response['message'] = "succes";
- }else {
- $response['error'] = true;
- $response['message'] = "Invalid username or password";
- }
- }else {
- $response['error'] = true;
- $response['message'] = "Required fields are missing";
- }
- public function userLogin($username, $pass) {
- $stmt = $this->conn->prepare("SELECT id FROM students WHERE s_id = ?");
- $stmt->bind_param("s", $username);
- $stmt->execute();
- $stmt_result = $stmt->get_result();
- if($stmt_result = $stmt->num_rows > 0) {
- while($row_data = $stmt_result->fetch_assoc(MYSQLI_ASSOC)) {
- # Action to do
- echo "success";
- }
- } else {
- # No data actions
- echo 'No data here :(<br/>';
- }
- }
Add Comment
Please, Sign In to add comment