Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/gavafue/registroComponentesMultimedia/llms.txt

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

The application uses a single MySQL (or MariaDB) database named isbo_prestamos with two tables: loans, which records every equipment checkout and return, and users, which stores administrator credentials. This guide walks you through creating the database, defining the schema, and seeding the first admin account.

Create the Database

Connect to the MySQL shell as root (or another user with the CREATE privilege):
mysql -u root -p
Then create the database with UTF-8 encoding:
CREATE DATABASE isbo_prestamos CHARACTER SET utf8 COLLATE utf8_general_ci;
USE isbo_prestamos;

Create the Tables

1

Create the loans table

The loans table is the core of the application. It stores the full lifecycle of each equipment loan, from checkout through return, including digital signatures captured in the browser as Base64-encoded PNG data URLs.
CREATE TABLE loans (
  id INT AUTO_INCREMENT PRIMARY KEY,
  ci VARCHAR(10) NOT NULL,
  name VARCHAR(150) NOT NULL,
  group_name VARCHAR(100) DEFAULT NULL,
  equipment_details TEXT NOT NULL,
  checkout_time DATETIME NOT NULL,
  checkout_signature LONGTEXT NOT NULL,
  return_time DATETIME DEFAULT NULL,
  return_signature LONGTEXT DEFAULT NULL,
  return_observation VARCHAR(500) DEFAULT NULL,
  status ENUM('active', 'returned') NOT NULL DEFAULT 'active'
);
Column reference:
ColumnTypeDescription
idINTAuto-incremented primary key
ciVARCHAR(10)Borrower’s national ID (cédula de identidad)
nameVARCHAR(150)Borrower’s full name
group_nameVARCHAR(100)Class or group the borrower belongs to (optional)
equipment_detailsTEXTDescription of the borrowed equipment
checkout_timeDATETIMETimestamp when the loan was created
checkout_signatureLONGTEXTBase64 PNG data URL of the borrower’s signature at checkout
return_timeDATETIMETimestamp when the equipment was returned (NULL if active)
return_signatureLONGTEXTBase64 PNG data URL of the borrower’s signature at return
return_observationVARCHAR(500)Optional notes recorded at return time
statusENUM'active' while on loan; 'returned' once equipment is back
checkout_signature and return_signature store Base64-encoded PNG data URLs generated by the browser’s signature canvas. These strings can be several kilobytes each — LONGTEXT (up to ~4 GB) is used to ensure no data is silently truncated. If you use an external signature storage solution in the future, these columns can be changed to VARCHAR(2048) for a URL reference instead.
2

Create the users table

The users table holds administrator accounts. Passwords are stored exclusively as bcrypt hashes — never in plain text.
CREATE TABLE users (
  id INT AUTO_INCREMENT PRIMARY KEY,
  username VARCHAR(60) NOT NULL UNIQUE,
  password_hash VARCHAR(255) NOT NULL
);
The UNIQUE constraint on username prevents duplicate admin accounts and ensures auth.php can look up a user by name without ambiguity.

Insert the First Admin User

Never store plain-text passwords. Always hash passwords with PHP’s password_hash() before inserting them into the database. Storing a plain-text password in the password_hash column will permanently lock you out of the application, because auth.php uses password_verify() to authenticate logins.
1

Generate the password hash

Run this one-liner on the server (or any machine with PHP installed) to produce a bcrypt hash for your chosen password:
php -r "echo password_hash('yourpassword', PASSWORD_DEFAULT);"
The output will look similar to:
$2y$10$K9L1GzP5xQe7VnRm8TsW0eBfXjH3cNdYgUoIpA4sLwMqZvkt6Ouer
Copy the entire hash string, including the leading $2y$.
2

Insert the admin record

Back in the MySQL shell, paste the hash into the following statement:
INSERT INTO users (username, password_hash)
VALUES ('admin', '<paste_hashed_password_here>');
For example:
INSERT INTO users (username, password_hash)
VALUES ('admin', '$2y$10$K9L1GzP5xQe7VnRm8TsW0eBfXjH3cNdYgUoIpA4sLwMqZvkt6Ouer');
Verify the record was inserted:
SELECT id, username FROM users;

Changing an Admin Password

To update an existing administrator’s password, generate a new hash with the PHP one-liner above and run the following UPDATE statement:
UPDATE users
SET password_hash = '<new_hash>'
WHERE username = 'admin';
Always regenerate the hash on the server — do not reuse hashes from previous installs or copy them from another source.

Connecting the Application to the Database

The database connection is configured in api/config.php. After creating the database and tables, open that file and verify the credentials match your environment:
$host     = 'localhost';
$db_name  = 'isbo_prestamos';
$username = 'root';          // Change if using a dedicated DB user
$password = 'rootapps2026';  // Change to your actual MySQL root password
The default credentials in api/config.php (root / rootapps2026) are suitable for local XAMPP development only. Before deploying to a production server, create a dedicated MySQL user with minimal privileges and update config.php accordingly. Then restrict access to the file using the steps in the Permissions guide.
The application uses PHP’s PDO extension with PDO::ERRMODE_EXCEPTION and PDO::FETCH_ASSOC, so any connection failure will return a JSON error response with HTTP 500 rather than a raw PHP fatal error.

Build docs developers (and LLMs) love