2

Here is my code:

<?php
$name = $_POST['name'];
$email = $_POST['email'];
$subject = $_POST['subject'];
$message = $_POST['message'];
$formcontent = "From: $name \n Email: $email \n Subject: $subject \n Message: $message";
$recipient = "hunter@dreaminginhd.com";
$subject = "Contact Form";
$mailheader = "From: $email \r\n";
mail($recipient, $subject, $formcontent, $mailheader) or die("Error!");
?>

I just need to know how to redirect to an HTML page after clicking submit and to make sure that the script with send the email. Any help will be greatly appreciated!

Hanson Hunter
  • 21
  • 1
  • 1
  • 3

4 Answers4

2

Add this to the end of the script:

header("Location: URL");

where URL is the URL of the page you want to redirect to.

Barmar
  • 741,623
  • 53
  • 500
  • 612
0

php

header('Location: login.php?msg=1');

javascript

<script> window.location='forgot.php'</script>";

html

<META HTTP-EQUIV="REFRESH" CONTENT="3;URL=http://google.com">
Chandru
  • 133
  • 10
0

You are possibly missing the open form and close form or you just include it

 <form name="PL" action="newForm.php" method="post">
 <?php
 $name = $_POST['name'];  
 $email = $_POST['email'];

 $subject = $_POST['subject'];

 $message = $_POST['message'];

 $formcontent = "From: $name \n Email: $email \n Subject: $subject \n Message:   
 $message";

 $recipient = "hunter@dreaminginhd.com";

 $subject = "Contact Form";

 $mailheader = "From: $email \r\n";

 mail($recipient, $subject, $formcontent, $mailheader) or die("Error!");  
include "newForm2.php";
 ?>
 <input type="submit" name="btn_submit" value="Display Invoice" /> 
 </form>
KarlosFontana
  • 188
  • 2
  • 7
  • For the mail() function to work your php.ini file needs correct SMTP settings. also it depends if you are sending via POP3 or IMAP. – KarlosFontana Oct 11 '13 at 20:43
0

First we get the mailto function to work with localhost and email client:
Check this link on stackoverflow:
URL link: send email to owner by collecting information provided by user through form?

Then I recommend using Swiftmailer. http://swiftmailer.org/docs/sending.html They got the best manual.

Community
  • 1
  • 1
KarlosFontana
  • 188
  • 2
  • 7