Intisar Kassab Intisar Kassab - 1 year ago 65
PHP Question

php redirect isn't working right

I have a problem with my redirect in php. The problem is that it redirects the user when they first load the page, I'm trying to make it redirect them when they submit the form... my code:

$name = $_POST['name'];
$email = $_POST['email'];
$contact = $_POST['contact'];
$address = $_POST['address'];

<!DOCTYPE html>
<h1>Example HTML</h1>

It may be my host cause I used a different host in the past and this php code worked :/ do you know any way I can get this php code working on my current host? It'd be really great if you helped

Answer Source

Even if you put header to if statement you should stop script execution because of sometimes PHP might throw an exception that HEADERS ALREADY SENT. So you should do something like this :

    header('Location: blabla');
    return false;
<!DOCTYPE html>