auto redirect
Moderator: General Moderators
auto redirect
i am using the mail function. if the used does not put in anything for the email address, i want the user to be redirected to an other url.
i am using this:
<?php
if ($email="") header("location: http://www.otherurl.com");
?>
it does not seem to be working. any idea what i am doing wrong.
thanks hans
i am using this:
<?php
if ($email="") header("location: http://www.otherurl.com");
?>
it does not seem to be working. any idea what i am doing wrong.
thanks hans
try:
if $email is a value from a form field then you need to use $_POST['email'].
Code: Select all
<?php
if(empty($email))
{
header("location: url here");
}
?>Code: Select all
<?php
if ($email=="")
header("location: http://www.otherurl.com");
?>if there is any output before you use [php_man]header[/php_man], it won't work.
e.g.
Will give you the same error, while if you remove the first line ("echo ...") it will work.
e.g.
Code: Select all
<?php
echo "Thanks for registering, dude.";
header ("location: http://forums.devnetwork.net");
?>i now have this:
if ($email=="") header ("Location: http://www.whatever.com");
but nothing happens.
any ideas?
thanks
if ($email=="") header ("Location: http://www.whatever.com");
but nothing happens.
any ideas?
thanks
by the way you always can echo a meta....
just so you know
just so you know
Code: Select all
<meta http-equiv="refresh" content="0; url=whatever.php" />Should try this techniqueqads wrote:try:Code: Select all
<?php if(empty($email)) { header("location: url here"); } ?>