index.html
Código HTML:
Ver original
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <link rel="shortcut icon" href="images/1.ico"/> <link rel="stylesheet" type="text/css" href="estilos/style.css" /> </head> <body> <div align="center"> <form id="login-form" action="verifica.php" method="post"> <fieldset> <input type="text" id="usuario" name="usuario" /> <input type="password" id="password" name="password"/> <!--<label for="recordarme" style="padding: 0;">recordarme?</label> <input type="checkbox" id="recordarme" style="position: relative; top: 3px; margin: 0; " name="recordarme"/> <div class="clear"></div>--> <br /> <input type="submit" style="margin: -10px 0 0 265px;" class="button" name="commit" value="ENTRAR"/> </fieldset> </form> </div> </body> </html>
verifica.php
Código PHP:
<?php
ob_start();
include("config.php");
// conecta servidor mysql
$link = mysql_connect($server, $db_user, $db_pass)
or die ("Could not connect to mysql because ".mysql_error());
// seleciona base de datos
mysql_select_db($database)
or die ("Could not select database because ".mysql_error());
$match = "select id from $table where usuario = '".$_POST['usuario']."'
and password = '".$_POST['password']."';";
$qry = mysql_query($match)
or die ("Could not match data because ".mysql_error());
$num_rows = mysql_num_rows($qry);
if ($num_rows <= 0) {
header("location:index.html");
exit;
} else {
setcookie("loggedin", "".$_POST['usuario']."", time()+(1800));
echo "<body style=' background: url(images/fondo3.jpg);'>";
echo "<center><img src='images/loading6.gif'><br><br><font color =#ffffff>Ingresando...</font>";
echo "<meta http-equiv='Refresh' content='2;url=principal.php'>";
}
ob_end_flush();
?>