Cari esperti,
vi sottopongo un piccolo problema.
Ho questa form di autenticazione semplicissima.
Il codice è il seguente.
Codice PHP:
<html>
<head>
<title>Log in</title>
</head>
<body><center>
Welcome to login area, please login with your username and pasword.
</center>
<form method=post action=<?php print("$PHP_SELF");?>>
<div align="center">[b]Username[/b]:
<input type="text" size=15 name="user">
[b]Pass[/b]:
<input type="password" size="15" name="pass">
<input type="SUBMIT" name="send" value="invia">
</div>
</FORM>
<?php
ob_start();
if ($_POST['user']=="user"&&$_POST['pass']=="pass")//change these to what ever you want them to be.
{
header("Location: [url]http://www.convertini.com[/url]");
}
else
{
if ($_POST['user'] == NULL)
{
}
else
print("Spiacente, [b][i]$user[/i][/b] non è un nome corretto.");//this is the error message, you can change it if you want.
}
?>
<center>
<?php
print ("Immanuel_Kant: the unprofessional choice");
?>
</body>
</html>
Lo script è visualizzabile a:
qui
Come è facile vedere si ottiene il messaggio seguente:
codice:
Warning: Cannot modify header information - headers already sent by (output started at /home/converti/public_html/aut/aut3/pass.php:14) in /home/converti/public_html/aut/aut3/pass.php on line 28
Ho fatto un po' di ricerche sul forum e l'adagio è stato:
Tra l'inizio dello script e il header(); non devono essere presenti echo, print, printf o altre funzioni che creano un output (per il browser).
Non vedo però questa ricorrenza.
Attendo vostri lumi.
Thanks