Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/IvBanzaga/Refugio/llms.txt

Use this file to discover all available pages before exploring further.

Overview

Authentication functions handle user verification and login processes in the Refugio mountain refuge reservation system.

Functions

comprobar_username

Verifies a user by their email address and retrieves their account information.
conexion
PDO
required
Database connection object
email
string
required
User’s email address to verify
return
array|false
Returns user data array on success, false on failure. User array contains:
  • id - User ID
  • email - User email
  • password - Hashed password
  • rol - User role
  • nombre - First name
  • apellido1 - First surname

SQL Query

SELECT id, email, password, rol, nombre, apellido1 
FROM usuarios 
WHERE email = :email

Code Example

$email = 'user@example.com';
$user = comprobar_username($conexion, $email);

if ($user) {
    if (password_verify($password_input, $user['password'])) {
        // Login successful
        $_SESSION['user_id'] = $user['id'];
        $_SESSION['rol'] = $user['rol'];
    }
} else {
    // User not found
}

Error Handling

Errors are logged to the error log and the function returns false:
error_log("Error al comprobar usuario: " . $e->getMessage());

Build docs developers (and LLMs) love