AwadGorg
1 month ago
121
1
General

is currently unable to handle this request. on form post submit

Posted 1 month ago by AwadGorg

Hello, I have this login system that works with no issues on my localhost but when uploaded to the server it returns an error collage-clinic.epizy.com is currently unable to handle this request. could it be cuz of hosting cuz am using infinityfree anyway that's the code

<?php
/*
 * Tutorial: PHP Login Registration system
 *
 * Page index.php
 * */

// Start Session
session_start();
include '../db.php';
// Application library ( with DemoLib class )
require __DIR__ . '/../functions/register.php';
$app = new DemoLib();

$login_error_message = '';
$register_error_message = '';

// check Login request
if (!empty($_POST['btnLogin'])) {

    $log_email = trim($_POST['log_email']);
    $log_password = trim($_POST['log_password']);

    if ($log_email == "") {
        $login_error_message = 'البريد الالكتروني ضروري';
    } else if ($log_password == "") {
        $login_error_message = 'كلمة السر ضرورية';
    } else {
      $app->init();
        $user_id = $app->Login($log_email, $log_password, 'students'); // check user login
        die($user_id);
        if($user_id > 0)
        {
            $_SESSION['id'] = $user_id; // Set Session
            header("Location: ../profile/user.php"); // Redirect user to the profile.php
        }
        else
        {
            $login_error_message = 'Invalid login details!';
        }
    }
}

and this

public function Login($email ,$password, $table)
    {
        try {
            die('dxvm,d');
            $db = DB();
            if ($table == 'students') {
              $role = 1;
              die($db);
              $query = $db->prepare("SELECT id FROM users WHERE
                email=:email AND password=:password AND role = :role");
            }elseif ($table == 'doctors') {
              $role = 2;
              $query = $db->prepare("SELECT id FROM users WHERE
                email=:email AND password=:password AND role = :role");
            }

            $query->bindParam(":email", $email);
            $query->bindParam(":role", $role, PDO::PARAM_INT);
            $enc_password = hash('sha256', $password);
            $query->bindParam(":password", $enc_password);

            $query->execute();
            if ($query->rowCount() > 0) {
                $result = $query->fetch(PDO::FETCH_OBJ);
                return $result->id;
            } else {
                return false;
            }
        } catch (PDOException $e) {
            exit($e->getMessage());
        }
    }

Please sign in or create an account to participate in this conversation.