Jump to content

Form Help with Confirmation Page


ruralscot

Recommended Posts

Hopefully someone can help prior to scratching my head through the my brain!!!

 

I have a code all sorted for a very quick form, all is working well and I am receiving the messages on test. My problem is that I would like, once the person presses submit they are then taken to a confirmation page eg contact2.html

 

Can anyone please help me on this?

 

At the moment it just echo's to thank you message

 

Many thanks

 

Allan

Link to comment
https://forums.phpfreaks.com/topic/198233-form-help-with-confirmation-page/
Share on other sites

hi 182guy

 

ok i'll explain I am a complete php newbie  :shrug:

 

This is the simple code I have at present:-

 

<?php

{

$to = "myemailaddress";

$subject = "Enquiry";

$name_field = $_POST['name'];

$email_field = $_POST['email'];

$message = $_POST['enquiry'];

 

$body = "From: $name_field\n E-Mail: $email_field\n Message:\n $message";

 

mail($to, $subject, $body);

}

?>

Hi again...dunce here again

 

Ok now i get the following

 

Warning: Cannot modify header information - headers already sent by (output started at /home/sites/allanlaw.co.uk/public_html/mailer.php:2) in /home/sites/allanlaw.co.uk/public_html/mailer.php  on line 13

 

 

this is the coding I have in mailer.php

 

<?php

{

$to = "[email protected]";

$subject = "Enquiry";

$name_field = $_POST['name'];

$email_field = $_POST['email'];

$message = $_POST['enquiry'];

$body = "From: $name_field\n E-Mail: $email_field\n Message:\n $message";

 

mail($to, $subject, $body);

 

header("Location: contact2.html"); /* Redirect browser  to thankyou.html */

 

/* Make sure that code below does not get executed when we redirect. */

exit;

}

?>

Hi again

 

Ok this is part of this page www.allanlaw.co.uk/contact.html and the mailer.php file is:-

 

<?php

{

$to = "[email protected]";

$subject = "Enquiry";

$name_field = $_POST['name'];

$email_field = $_POST['email'];

$message = $_POST['enquiry'];

$body = "From: $name_field\n E-Mail: $email_field\n Message:\n $message";

 

mail($to, $subject, $body);

 

header("Location: contact2.html"); /* Redirect browser to contact2.html */

 

/* Make sure that code below does not get executed when we redirect. */

exit;

}

?>

 

The actual contact page code is:-

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">

<head>

<title>Photography - Contact</title>

<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />

<link rel="stylesheet" type="text/css" href="../style/style.css" />

<link rel="stylesheet" type="text/css" href="../style/colour.css" />

</head>

<body>

<div id="logo">

  <h1>ruralscotland photography</h1>

  <div id="links"></div>

</div>

<div id="menu">

  <ul>

    <li><a href="../index.html">home</a></li>

    <li><a href="http://www.allanlaw.co.uk/pricing.html">pricing</a></li>

    <li><a class="selected" href="http://www.allanlaw.co.uk/contact.html">contact</a></li>

  </ul>

</div>

<div id="site_content">

  <div id="side_menu">

    <div class="side_menu_item"> <img src="../style/series_one.jpg" alt="" width="142" height="50" /> <span class="info">Wedding</span> </div>

    <div class="side_menu_item"> <a href="land.html"><img src="../style/series_two.jpg" alt="" width="142" height="50" /></a> <span class="info">Landscapes</span> </div>

    <div class="side_menu_item"> <a href="comm.html"><img src="../style/series_three.jpg" alt="" width="142" height="50" /></a> <span class="info">Commission</span> </div>

    <div class="side_menu_item"> <img src="../style/series_four.jpg" alt="" width="142" height="50" /> <span class="info">Playtime</span> </div>

    <div class="side_menu_item"> <img src="../style/series_five.jpg" alt="" width="142" height="50" /> <span class="info">Misc</span> </div>

  </div>

  <div id="content">

    <h1>contact</h1>

    <p>Contact form: Please complete or simply email [email protected], if sending form please be sure to check SPAM folder as sometimes our email address can be treated as SPAM.</p>

    <p></p>

    <form id="contact" method="post" action="mailer.php">

      <div class="row1"> <span class="formlabel">your name</span> <span class="forminput">

        <input type="text" name="name" />

        </span> </div>

      <div class="row1"> <span class="formlabel">your email address</span> <span class="forminput">

        <input type="text" name="email" />

        </span> </div>

      <div class="row1"> <span class="formlabel">your enquiry</span><span class="forminput">

        <textarea cols="28" rows="11" name="enquiry" class="textarea"></textarea>

      </span></div>

      <div class="spacer"> </div>

      <div class="row1"> <span class="formlabel"></span><span class="forminput">

        <input type="submit" value="submit" class="submit" />

      </span></div>

    </form>

  </div>

</div>

</body>

</html>

 

It looks like you might have some space before the <?php tag in your mailer.php file. Make sure there is no whitespace before the open page tag: <?php

 

If there is, then the whitespace will be treated as output and sent to the browser.

 

Are there any other error messages?

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.