Ive been developing this project for a while and after finishing developing it on my local server I uploaded it to Hostinger. However now the inc files whic process the users input wont work. Ive checked and the database connection has the correct credentials.
Ive added in var_dumps to show that it is correctly taking in the data
https://emilyanddavid2025.co.uk/02_guest_login.php
<?php
if ($_SERVER["REQUEST_METHOD"] === "POST") {
$username = $_POST["username"]; // ADD FEATURE TO SANITIZE THE USER INPUT TO PREVENT ATTACKS
var_dump($username);
try {
require_once 'dbh.inc.php';
require_once 'guest_login_model.inc.php';
// VIEW WOULD GO HERE IF NEEDED
require_once 'guest_login_contr.inc.php';
$errors = [];
if (is_input_empty($username)) {
$errors["empty_input"] = "Fill in username!";
}
$result = get_user($pdo, $username);
var_dump($result);
if (!isset($errors["empty_input"])) {
if (is_username_wrong($result)) {
$errors["login_incorrect"] = "Incorrect username!";
}
}
require_once 'config_session.inc.php';
if ($errors) {
$_SESSION["errors_login"] = $errors;
header("location: ../02_guest_login.php");
die();
}
$newSessionId = session_create_id();
$sessionId = $newSessionId . "_" . $result["id"];
session_id($sessionId);
$_SESSION["user_id"] = $result["id"];
$_SESSION["user_username"] = htmlspecialchars($result["username"]);
$_SESSION["user_guest_one"] = htmlspecialchars($result["guest_one"]);
$_SESSION["user_guest_two"] = htmlspecialchars($result["guest_two"]);
$_SESSION["user_guest_three"] = htmlspecialchars($result["guest_three"]);
$_SESSION["user_guest_four"] = htmlspecialchars($result["guest_four"]);
$_SESSION["last_regeneration"] = time();
var_dump($_SESSION["user_guest_one"]);
header("location: ../03_rsvp.php");
$pdo = null;
$statement = null;
die();
} catch (PDOExeption $e) {
die("Query failed: " . $e->getMessage());
}
} else {
header("location: ../02_guest_login.php");
die();
}
This file should correct identify whether the guest username exists via checks and it would then redirect them accordingly.