function.php
main.php
login.php
index.php
al incresar a index.php:
Código PHP :
<?php session_start();?>
<?php require("include/functions.php");?>
<!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" />
<title>Documento sin título</title>
</head>
<body>
<?php
echo "<i>".session_msg()."</i>";
?>
<form action="login.php" method="post">
<table>
<tr><td>Usuario:</td><td><input type="text" name="username"></td></tr>
<tr><td>Contraseña:</td><td><input type="password" name="password"></td></tr>
<tr><td></td><td><input type="submit" value="Ingresar"></td></tr>
</table>
</form>
</body>
</html>me lleva a login.php:
Código PHP :
<?php session_start();?>
<?php require("include/functions.php");?>
<!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" />
<title>Documento sin título</title>
</head>
<body>
<?php
$username = isset($_POST["username"])?$_POST["username"]:"";
$password = isset($_POST["password"])?$_POST["password"]:"";
if(empty($username) || empty($password))
{
redirect_to("index.php");
}
mysql_connect("localhost","XXXXXX","XXXXXX") or
die("No se ha podido conectar a la base de datos");
mysql_select_db("radiopix_user") or
die("No se ha podido seleccionar la base de datos");
$query = "SELECT * FROM users WHERE username='".$username."' LIMIT 1";
$result = mysql_query($query);
if(mysql_num_rows($result) == 1)
{
$user = mysql_fetch_assoc($result);
if($user["password"] == $password)
{
$_SESSION["username"] = $username;
session_msg("Ha iniciado sesión.");
redirect_to("main.php");
}
else
{
session_msg("Password Incorrecto.");
redirect_to("index.php");
}
}
else
{
session_msg("Nombre de usuario inexistente.");
redirect_to("index.php");
}
?>
</body>
</html>esta me indica el siguiente error:
Warning: Cannot modify header information - headers already sent by (output started at /home/radiopix/public_html/login/include/functions.php:8) in /home/radiopix/public_html/login/include/functions.php on line 22 escribió:
que algo anda mal en function.php el codigo de function.php es:
Código PHP :
<!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" />
<title>Documento sin título</title>
</head>
<body>
<?php
function session_msg($msg="")
{
if(empty ($msg))
{
return isset($_SESSION["message"])?$_SESSION["message"]:"";
}
else
{
$_SESSION["message"] = $msg;
}
}
function redirect_to($url)
{
header("Location:".$url);
exit();
}
?>
</body>
</html>El error me indica que esta mal la linea 22 la cual se encuentra:
Código PHP :
header("Location:".$url); 
