Jump to content

php redirect


thaven

Recommended Posts

I am new to php.  Can someone help me?  I have set up a php script for a contact html.  It forwards a form filled out people visiting my website to my email.  But I would like for the php script to redirect the visitor to an html I created.  It seems I can do one or the other.  Not both.  Please help? Someone?

Link to comment
https://forums.phpfreaks.com/topic/110532-php-redirect/
Share on other sites

Example HTML Form:

 

form.php

<form action="submit.php" method="post">
<p>Name: <input type="text" name="name" /></p>
<p>Email: <input type="text" name="email" /></p>
<p>Age: <input type="text" name="age" /></p>
<p><input type="submit" name="submit" /></p>
</form>

 

 

Example Mail Form:

 

submit.php

if(isset($_POST['submit'])){
     $message = 'This was sent by '.$_POST['name'].' my email is '.$_POST['email'].' and I am '.$_POST['age'].' years old!';
     if(mail('[email protected]','Hello Pal!',$message)){
          header("Location: success.php");
          extit;
     }else{
          header("Location: form.php");
          exit;
     }
}else{
     header("Location: form.php");
     exit;
}

 

Example success page

 

success.php

<html>
<head>
<title>SUCCESS!</title>
</head>
<body>
<h1>YOUR MESSAGE WAS SENT!</h1>
</body>
</html>

Link to comment
https://forums.phpfreaks.com/topic/110532-php-redirect/#findComment-567055
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.