Cita:
Iniciado por Avatar810
tenias correcta la idea solo se te fue un detalle
La condicion para usar
header es no haber enviado nada a pantalla anteriormente (ni las cabeceras de html)
Sugiero este codigo
Código PHP:
<?
if (isset($_POST['enviar']))
{
$error="";
$name=$_POST['name'];
$password=$_POST['password'];
$connection = mysql_connect("localhost", "USUARIODB", "PASS WORDDB") or die ("Unable to connect to server");
$db = mysql_select_db("BASE_DE_DATOS", $connection) or die ("Unable to select database");
// query the database to see if there is a record which matches
$query = "select 1 from MITABLA where name='$name' and password='$password'";
$result = mysql_query($query, $connection) or die ("Query error");
if(mysql_num_rows($result)>0)
header("Location: QuezTal.php");
else
$error="Usuario o Contraseña INCORRECTOS<br /><br />";
}
else
{
?>
<html>
<head>
<style type="text/css">
body {background-color:#000000; color:#FF6600}
</style>
</head>
<body>
<h2> Esta página es secreta </h2>
<?= $error; ?>
<form method="post" action="secretdb.php">
Username:<br>
<input type="text" name="name">
<br>
Password: <br>
<input type="password" name="password">
<br>
<input type="submit" name="enviar" value="Enviar informacion">
</form>
</body>
</html>
<?
}
?>
De acuerdo, solucionado Pues! Muchas gracias Chicos!