Overview
The registration system allows new users to create accounts in Pro Stock Tool. The process includes comprehensive client-side and server-side validation to ensure data integrity and security.Registration Form
The registration page (login.html) provides a user-friendly interface for account creation with real-time validation.
Form Fields
The registration form (login.html:20-40) collects the following information:
| Field | Type | Name | Required | Placeholder | Validation |
|---|---|---|---|---|---|
email | email | Yes | [email protected] | Email format, unique | |
| Name | text | Nombre | Yes | Juan David | Min 2 chars, max 100 |
| ID Number | text | N-identidad | Yes | 1067623487 | 6-20 digits |
| Password | password | Contraseña | Yes | ************************ | Min 6 characters |
Registration Workflow
Duplicate check
System verifies email and ID number are not already registered (
registro.php:42-45).Field Specifications
Email Field
- Client-Side
- Server-Side
JavaScript regex validation (
registro.js:30):Email addresses must be unique. The system checks for existing emails before creating an account.
Name Field
- Minimum length: 2 characters
- Maximum length: 100 characters
- Client validation (
registro.js:43): - Server validation (
registro.php:29-31):
ID Number Field
- Format: Numeric only
- Length: 6 to 20 digits
- Uniqueness: Must not exist in database
- Client-Side
- Server-Side
registro.js:44):Password Field
- Show/Hide Toggle: Button to reveal password (
registro.js:22-28) - Minimum Length: 6 characters
- Secure Storage: BCrypt hashing
- Client-Side
- Server-Side
registro.js:22-28):
Form Submission Process
Client-Side Submission
The form submission is handled via JavaScript (registro.js:34-63):
The form uses
novalidate attribute to implement custom JavaScript validation instead of default HTML5 validation.Server-Side Processing
The backend endpoint (registro.php) processes registration requests:
Request Validation
Data Sanitization
Duplicate Prevention
Password Hashing & Database Insertion
Alert System
The registration page includes a custom alert component (login.html:44-47):
registro.js:12-16):
API Response Format
Success Response
Error Responses
- “Método no permitido”
- “Datos inválidos”
- “Email inválido”
- “Nombre inválido”
- “Identidad inválida”
- “Contraseña muy corta”
- “Email o Identidad ya registrados”
- “Error al registrar: [database error]”
- “Error del servidor: [exception message]“
Security Features
BCrypt Hashing
Passwords are hashed using BCrypt with automatic salt generation before database storage.
SQL Injection Prevention
All user inputs are escaped using
real_escape_string() to prevent SQL injection attacks.Duplicate Prevention
System checks for existing email and ID numbers before allowing registration.
CORS Headers
Appropriate CORS headers are set for secure cross-origin requests.
Database Schema
Based on the code, theusuarios table includes:
| Column | Type | Description |
|---|---|---|
| id | INT | Auto-increment primary key |
| VARCHAR | User email (unique) | |
| nombre | VARCHAR | User full name |
| identidad | VARCHAR | ID number (unique) |
| password | VARCHAR | BCrypt hashed password |
| creado_en | TIMESTAMP | Account creation timestamp |
Best Practices
- Strong Passwords: While the minimum is 6 characters, encourage users to create longer, complex passwords
- Valid Email: Use a real email address for account recovery and notifications
- Unique Credentials: Each email and ID number can only be registered once
- Secure Connection: Always use HTTPS in production to protect credentials during transmission
Troubleshooting
Email inválido error
Email inválido error
Ensure the email follows the format:
[email protected]Examples of valid emails:N° Identidad inválido error
N° Identidad inválido error
The ID number must:
- Contain only digits (0-9)
- Be between 6 and 20 characters long
- Not contain spaces, letters, or special characters
Email o Identidad ya registrados
Email o Identidad ya registrados
This error occurs when:
- The email address is already in use by another account
- The ID number is already registered
Contraseña muy corta error
Contraseña muy corta error
Password must be at least 6 characters long. Consider using:
- A mix of uppercase and lowercase letters
- Numbers and special characters
- A passphrase for better security
Error de conexión
Error de conexión
This typically indicates:
- Network connectivity issues
- Server is down or unreachable
- CORS configuration problems
Next Steps
Authentication
Learn how to log in to your account
User Accounts
Understand account structure and management