Skip to content

Instantly share code, notes, and snippets.

@manuel-gonzalez-1988
Created June 9, 2025 23:35
Show Gist options
  • Save manuel-gonzalez-1988/9835f53cead7c426d1913971bb14e310 to your computer and use it in GitHub Desktop.
Save manuel-gonzalez-1988/9835f53cead7c426d1913971bb14e310 to your computer and use it in GitHub Desktop.
procesar
<?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