Redirect page after an email form

Asked

Viewed 3,833 times

1

I am making a form that needs to reach my email but when someone clicks on Ubmit it is redirected to a thank you page. Grateful.

1 answer

1


Create the page redirect.php - which will be the page that checks the form data and will redirect the user to the thank you page - and write the following code:

<?php    
    if (isset($_POST['submicao']))
    {   
       <!-- faça a validação dos dados submetidos !-->

       header('Location: http://seusite/agradecimento.php');       
    }
?>

On your form page, do a redirect page include right after the form submission

<html>
<head>
    <!-- Código do header !-->
</head>

<body>

    <form>
        <!-- Seus labels, etc. do formulario !-->

        <!-- Página de redirecionamento -->
        <?php include "include/redirecionamento.php"; ?>

    </form>
</body>
</html>

Or you can also use the following javascript code within the tag <form>

<form onsubmit="window.location.href='redirecionamento.php';">

In that case, you wouldn’t need to give the "include".

<body>

    <form onsubmit="window.location.href='redirecionamento.php';">>
        <!-- Seus labels, etc. do formulario !-->
    </form >
</body>
</html>
  • but I put this in the middle of the <head>?

  • @Luvinicius edited the answer to be clearer

  • Thanks, but in javascript is in the same position?

  • I changed the answer again :-)

  • Thanks a lot man! :)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.