Jump to content

Form submission and mailing


Carin

Recommended Posts

Hallo there!

I am a complete PHP noob so please go easy on me :)

 

What I need to do is the following: an invitation mail goes out and people click on a link to RSVP and is taken to this page:


 

Here people tick a radio box to say either "Yes" or "No" and they fill in their name(s). If they say "Yes", a mail should be sent with the Yes answer plus the names they entered and they should redirect to this page to thank them for their submission:


 

Should they tick "No", a mail should be sent that contains the "No" answer plus the name the user has entered and be redirected to this page to say sorry that they will not be attending:


 

I also have an error page if they have not selected anything: http://www.menusolutions.co.za/anch_error.html

 

What I need help with, please, is the PHP that compiles the mail. I was advised to have 3 PHP files - the first "deciding-mailer.php" simply test for Yes or No and then directs to another php file for Yes and yet another for No - here is where I fall down - when I select Yes or No and enter the names, it goes through to the correct response page, but I receive no email. I am also a bit worried about validation, of which there is none at the moment, so even if I enter no names, it still goes to the response page, so I would need to validate for no entries and then redirect to the error page.

 

I attach my php files.

 

Could you please be so kind as to let me know where I have gone wrong / what I am missing? Please treat me as a complete idiot :P

deciding-mailer.php

no.php

yes.php

Link to comment
https://forums.phpfreaks.com/topic/287023-form-submission-and-mailing/
Share on other sites

Hi again Carin; Reviewed your code again...

 

Create a *.php page and send your radio form to it: (CODE NOT TESTED!!!) Have a play around see how you go...

                $webmaster_email = "[email protected]";

		$to      = 	'$webmaster_email';
		$subject = 	'< Subject goes here >';
		$headers = 	'From: $webmaster_email' . "\r\n" .
				'Reply-To: $webmaster_email' . "\r\n" .
				'X-Mailer: PHP/' . phpversion();

		if (isset($_POST['ja_nee'])){
				$ja_nee = $_POST['ja_nee'];	
			}else{
				$ja_nee = "";
			}
		
		if ($ja_nee == 'Yes'){
				// YES
				$message = "Ja-of-Nee: <Message goes here>"; 
				mail($to, $subject, $message, $headers);
				$thankyou_page = "anch_yes.html";
				header( "Location: $thankyou_page" );
		
		} else if ($ja_nee == 'No'){
				// NO
				$message = "Ja-of-Nee: <Message goes here>"; 
				mail($to, $subject, $message, $headers);
				$thankyou_page = "anch_no.html";
				header( "Location: $thankyou_page" );
		}

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.