Created
June 9, 2025 23:35
-
-
Save manuel-gonzalez-1988/9835f53cead7c426d1913971bb14e310 to your computer and use it in GitHub Desktop.
procesar
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
session_start(); | |
if ($_SERVER["REQUEST_METHOD"] == "POST") { | |
$usuario = trim($_POST["usuario"]); | |
$password = trim($_POST["password"]); | |
// Validaciones básicas | |
if (strlen($usuario) < 3 || strlen($password) < 5) { | |
echo "El nombre de usuario debe tener al menos 3 caracteres y la contraseña 5."; | |
exit; | |
} | |
// Guardar usuario en archivo | |
$linea = $usuario . ":" . $password . PHP_EOL; | |
file_put_contents("usuarios.txt", $linea, FILE_APPEND); | |
// Guardar sesión | |
$_SESSION["usuario"] = $usuario; | |
// Redireccionar a la página de bienvenida | |
header("Location: bienvenida.php"); | |
exit; | |
} else { | |
echo "Acceso no válido."; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment