Je suis un amateur en php & je suis entraîne de faire un programme qui permettra d'aller dans un jeux par connexion. Le problème s'est que lorsque je clique sur le bouton submit, c'était censer faire devenir l'élément 'alerta' visible. Au lieu de ça, l'element 'alerta' devient visible & rapidment, il devient hidden. Que faire pour que ça reste visible en permanent?
<?php
define('login','william');
define('mdp','abc123');
$mensaje = '';
if(empty($_POST['nombre']))
{
$mensaje = 'Llena el formulario.';
}
elseif(empty($_POST['mdp']))
{
$mensaje = 'Pon tu contrasena';
}
elseif(empty($_POST['mdp']) && empty($_POST['nombre']))
{
$mensaje = 'Llena el formulario';
}
elseif($_POST['nombre'] !== login || $_POST['mdp'] !== mdp)
{
$mensaje = 'Tu nombre o tu contresena es malo';
}
elseif($_POST['nombre'] !== login && $_POST['mdp'] !== mdp)
{
$mensaje = 'Tu nombre o tu contresena es malo';
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr">
<head>
<title>juego.php - conectate ahora.</title>
</head>
<style type="text/css">
body
{
background-color:#00FFA2;
font-family:tahoma;
}
#pagina
{
background-color:#DBFFF2;
width:340px;
position:relative;
top:250px;
}
#conexion
{
border:1px solid #00AB6D;
background-color:#00D486;
font-family:tahoma;
color:#B3FFE3;
}
#alerta
{
border:1px solid black;
background-color:red;
font-size:13px;
visibility:hidden;
}
</style>
<body>
<center>
<div id="pagina">
<br>
<form name="formulario" method="post">
<span id="alerta"><?php echo $mensaje; ?></span><br>
Nombre : <input type="text" name="nombre" id="nombre"><br>
Contrasena : <input type="password" name="mdp" id="mdp"><br>
<input type="submit" value="conectarse" id="conexion" name="conexion" onclick="document.getElementById('alerta').style.visibility = 'visible'"><br>
</form>
<br>
</div>
</center>
</body>
</html>