Ejemplo filter_input

<form action="contenido.php" method="post">
 Introduce Nombre: <input type="text" name="nombre">
 Introduce Password: <input type="password" name="password">
 <input type="submit">

</form>

 

<?php
 $nombre = filter_input(INPUT_POST, "nombre");
 $password = filter_input(INPUT_POST, "password");

if (empty($nombre)) {
 ?>
 <p>Introduce el nombre, por favor</p>
 <a href="index.php">Volver</a>
 <?php
 die();
 }
 if (empty($password)) {
 ?>
 <p>Introduce el password, por favor</p>
 <a href="index.php">Volver</a>
 <?php
 die();
 }
 if ($nombre=="Juan" && $password=="1234"){
 echo "Adelante";
 }
 else{
 ?>
 <p>Datos incorrectos</p>
 <a href="index.php">Volver</a>
 <?php 
 }
 ?>

Publicado por

Avatar del usuario

Juan Pablo Fuentes

Formador de programación y bases de datos