I have searched the forum for solutions to this problem, and I´ve applied them all, but the problem persists.
I get the following error message when running the php file with session handling:
Warning: Cannot modify header information - headers already sent by (output started at C:\htdocs\baluffo\pruebas\sesiones\funciones.php:9) in C:\htdocs\baluffo\pruebas\sesiones\login.php on line 10
The scripts involved are this:
<?php
//login.php
if (($_POST['login']) && ($_POST['password']) )
{
session_start();
include('./funciones.php');
$error = verificar($_POST['login'], $_POST['password']);
if ($error==1)
{
$_SESSION["login_id"] = 1;
Header("Location: ./pagina1.php");
}
else
{
print "Error:$error";
echo '<form method="post">
Username : <input type="text" name="login"><br />
Password : <input type="password" name="password"><br />
<input type="submit" value="Entrar"></form> ';
}
}
else
echo '<form method="post">
Username : <input type="text" name="login"><br />
Password : <input type="password" name="password"><br />
<input type="submit" value="Entrar"></form> ';
?>
and this:
<?php
//funciones.php
function verificar($login, $password)
{
if ( ($login != 'prueba') && ($password != 'pass') )
return (0);
else if ( ($login == 'prueba') && ($password == 'pass') )
return (1);
}
?>
the page that should open when using a valid user/pass only includes an 'echo' sentence, it does not include session verification because it is only a sample script (same for the user/pass thing)
the weird thing is that if I put the 'include' sentence for the funciones.php script BEFORE session_start(), I get several errors of headers already sents, referred to cookies. as you see, funciones.php does not return ANY html info, the return codes do not print on screen.
I is very possible that the solution is obvious, but I cannot see it. Thanks in advance.