Jump to content
Larry Ullman's Book Forums

timmo

Members
  • Posts

    1
  • Joined

  • Last visited

timmo's Achievements

Newbie

Newbie (1/14)

0

Reputation

  1. Hi, I am a beginner at PHP and programming in general but have needed to have a working contact form on my business website. This is more than likely very easy but I just cannot get what I need working. I have been trying to implement the script to send an email from a HTML form. The script as written in the book prints a message on submission of the form but I want it to redirect to another page instead. I have looked around for the solution but cannot figure out how to make this work. I believe that I need to use : header('Location: applythanks.html');exit();I have put this into the code under the part that sends the message, which I do receive, but the page does not redirect. I have also tried putting it in other parts of the code but still do not get the desired result.The original script is as follows: <?php # Script 10.1 - email.php // Check for form submission: if (isset($_POST['submitted'])) { // Minimal form validation: if (!empty($_POST['name']) && !empty($_POST['email']) && !empty($_POST['comments']) ) { // Create the body: $body = "Name: {$_POST['name']}\n\nComments: {$_POST['comments']}"; // Make it no longer than 70 characters long: $body = wordwrap($body, 70); // Send the email: mail('your_email@example.com', 'Contact Form Submission', $body, "From: {$_POST['email']}"); // Print a message: echo '<p><em>Thank you for contacting me. I will reply some day.</em></p>'; // Clear $_POST (so that the form's not sticky): $_POST = array(); } else { echo '<p style="font-weight: bold; color: #C00">Please fill out the form completely.</p>'; } } // End of main isset() IF. // Create the HTML form: ?> I would be very grateful if someone could help me with this, as am tearing my hair out! Many thanks
×
×
  • Create New...