La duda que tengo es que en el manual de la función header() indican esto.
Código PHP:
<html>
<?php
/* Esto producirá un error. Fíjate en el html
* que se muestra antes que la llamada a header() */
header('Location: http://www.example.com/');
?>
-----------------------------------------------------------------------
Pero yo tengo el siguiente script:
ex10.17.html
Código PHP:
<html><head><title>Redirecting the User</title></head>
<body bgcolor="#33ff33">
<form action="ex10.17.php" method="post">
<b>
Select a search engine<br>
</b>
<select name="new_url">
<option value="http://www.google.com" />Google
<option value="http://www.yahoo.com" /> Yahoo!
<option value="http://www.lycos.com" /> Lycos
<option value="/index.php" /> PHP Index
</select>
<input type="submit" value=" Get the Web Page!" />
</b>
</form>
</body>
</html>
Código PHP:
<html>
<h1>dsdsds</h1>
<?php
if($_POST[new_url] == ""){
exit;
}
else {
header("Location: $_POST[new_url]");
exit;
}
?>
Según indica la función no debe haber ningún caracter html, ni espacio en blanco ni resultado antes del header(), porqué funciona?