extracto de index.php
Código HTML:
<form action="my.php" method="post" name="login" target="_top"> <table width="100%" border="0" cellspacing="0" cellpadding="0" class="form"> <tr> <td><Login:</td> <td><input name="user" type="text" size="14"></td> </tr> <tr> <td>Password: </td> <td><input type="password" name="pass" size="14"></td> </tr> <tr> <td colspan="2" align="center"><input name="remember" value="yes" type="checkbox"> Remeber me <input name="go" type="image" src="images/en-us/go.gif"></td> </tr> </table> </form>
Código PHP:
<?php
require_once("./includes/generalfunctions.php");
conectar();
$usuario = $_POST['user'];
$password= $_POST['pass'];
$query = mysql_query("SELECT Username, Password FROM tabla WHERE Username='$usuario' AND Password='$password'") or die("Invalid Query");
if($array = mysql_fetch_array($query)){
session_start();
$_SESSION['autentificado'] = "SI";
$_SESSION['usuario'] = $array["Username"];
} else {
header("Location: index.php?errorusuario=si");
}
?>
Código HTML:
Welcome, <?php echo "<strong>".$_SESSION['usuario']."</strong>"; ?>
Antes de que lo olvide...
Código PHP:
function conectar() {
global $host, $user, $pass, $db;
$link = mysql_connect($host, $user, $pass);
if ($link) {
$linkselect = mysql_select_db($db, $link);
if (!$linkselect) {
$errmsg = $strError_db;
}
}
else {
$errmsg = $strError_connection;
}
return $link;
}
Nos vemos,