Jump to content

mailform


crumpy1

Recommended Posts

I am looking to edit my php code to make my own webpages display my thank you message when people submit a form from my website.

 

I have attached the code of my current form, however these only produce basic text screens and i would like them to be redirected to a premade webpage so it doesnt look so tackey. I am new to php but am desperatly trying to grasp the basics.

 

I am trying to also send a copy of the submited form back to the sender via email, but again do not know where in this code it goes.

 

Any Help would be much appreciated.

 

Thanks

17412_.php

Link to comment
Share on other sites

if you want to redirect the user to another webpage after a successful email send then change the end of your script to this:

<?php
// Send the email.
if ( mail($to, $subjectline, $body, $security, "-f".$email)) {
header('Location:confirmationpage.php'); // this will redirect the page to confirmation.php
// if you want to send a confirmation email to the customer then you could throw it in here

} else {
header('Location:failure.php');
   }

Link to comment
Share on other sites

if you want to redirect the user to another webpage after a successful email send then change the end of your script to this:

<?php
// Send the email.
if ( mail($to, $subjectline, $body, $security, "-f".$email)) {
header('Location:confirmationpage.php'); // this will redirect the page to confirmation.php
// if you want to send a confirmation email to the customer then you could throw it in here

} else {
header('Location:failure.php');
   }

 

Thank you so much for the help it is now loading my webpage. Your instructions were so clear so thank you!! Sorry to be a pain though but i have 1 more issue.

 

Now i have added validation to my form this code has caused me even more errors. it runs the code below which forces users to complete the non mandatory fields before submitting. How can i delete this section? i have tried deleting the code after 'else' but that produces a white page on submit. In this form also i would like the response to go to myself and the sender.

 

if any1 can help i would be extremeley appreciative.

 

Thanks

 

 

// The ['email'] should match the name= in the email text input box in your form. Used for email validation.

 

 

// DO NOT CHANGE THIS HERE. Change your form to match this.

 

 

$email = $_POST['email'] ; // collect users email from form for the email header.

 

 

// Collect all information from form and check all fields have been filled in.

 

 

if (sizeof($_POST)) {

 

 

$body = "";

 

 

while(list($key, $val) = each($_POST)) {

 

 

if ($key == "Submit") {

 

 

//do nothing

 

 

}

 

 

else {

 

 

$body .= "$key:\n $val\r\n";

 

 

// Checks if $val contains data

 

 

if(empty($val)) {

 

 

echo ("<b><p><li>One or more required fields have not been filled in.</li></p>

 

 

<p><li>Please go <a href='javascript: history.go(-1)'>Back</a> and try again</li></p></b>");

 

 

exit();

 

 

}

 

 

}

 

 

}}

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.