Creating a form that sends an email to inputted emails

I am looking for some help on a small project for my site.
I haven’t created anything yet but what I would like is a simple email form (which I could create)
But I would like it to have a section with 10 lines where you can input 10 email addresses.
Upon entering the emails, once submitted, it would send them a pre-designed email, inputting informations put into the form initially.

For example:

It could be a party invitation
You fill in host name, date of even, time, place, and 10 email addresses
It sends a pre-designed “invitation” to the 10 email recipients, inserting the host name, date, time etc in the email body where i would preset it to go.

Is this simple? Or is it difficult, requiring mysql etc.
Can anyone point me in the right direction?

Thanks!

Hello,

For someone with php knowledge is easy, if you are beginner i don’t think is easy.

http://www.w3schools.com/php/php_mail.asp
http://www.w3resource.com/php/mail/send-simple-mail-in-php.php
http://php.net/manual/en/function.mail.php

if you have a form already coded just post it here i will combine it with mailing codes i have

Thanks for the fast reply! I appreciate it!
I am a newbie with some things, expert at others, so we’ll see how this goes
Here’s what the form would look like, a rough idea anyways
I wasn’t sure how to make a line that when you inputted an email, it would send the predesigned email/invitation to them. I put two different lines in the “guest” lines, not sure if either are right?..

Where would I go from here?
TIA

[php]

Host (your name):

Event Date (dd/mm/yy):

Event Time:

Location:

Extra Comments:

Guest 1:


Guest 2: [/php]

You shouldn’t need two input for the recipients name. All you need are their emails.

[php]
$from = $_POST[‘senderEmail’];
$emailTo1 = $_POST[‘emailTo1’];
$subject = $_POST[‘subject’];
$date = $_POST[‘date’];
$event = $_POST[‘event’];
// Whatever other variables are needed

$message = "
		Put your desired email message in here.
	";
					
	$from = "$from";
	$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
	$headers .= "From: Invitation <$from>\r\n";

	mail($to,$subject,$message,$headers);

[/php]

Great, thanks!
Sorry to clarify, I want to be able to have not two but 10 spaces for the person to fill in 10 email addresses, and the email would send to all of them. I won’t know their addresses before hand, they will always change. how would I do that. please be specific to the above example, i am very new at this (and very confused) lo
l
How would I have it do this:
This is an invitation from (host name goes here).
The party is at (time goes here)
etc
This would be the desired email that I would fill in

This is what I have so far, I am lost
Trying to take the emails entered and make them the recipients of the new email that will be formatted next

[php]

Host (your name):

Event Date (dd/mm/yy):

Event Time:

Location:

Extra Comments:

Guest 1:


Guest 2:


Guest 3:

$from1 = $_POST[‘Guest1’];
$from2 = $_POST[‘Guest2’];
$from3 = $_POST[‘Guest3’];

	$from = $_POST['senderEmail'];
    $emailTo1 = $_POST['emailTo1'];
	$subject = $_POST['subject'];
    $date = $_POST['date'];
    $event = $_POST['event'];
    // Whatever other variables are needed

$message = "

Put your desired email message in here.

";

$from = “$from”;
$headers .= “Content-Type: text/html; charset=ISO-8859-1\r\n”;
$headers .= “From: Invitation <$from>\r\n”;

mail($to,$subject,$message,$headers);[/php]

this is a completely working script ( you should add style to the form and validation ).

[php]<?php
if(isset($_POST[‘sendInvite’])){

$from = $_POST['Name'];				// Who the email is from
$hostEmail = $_POST['hostEmail'];	// Host's email
$subject = $_POST['subject'];		// Subject line
$date = $_POST['date'];				// Event's date
$event = $_POST['event'];			// Name of the event
$Comments = $_POST['Comments'];		// Extra comments
	
/* 
	This builds the invite list
*/
$to = $_POST['Guest1'];
$to .= ", ".$_POST['Guest2'];
$to .= ", ".$_POST['Guest3'];
$to .= ", ".$_POST['Guest4'];
$to .= ", ".$_POST['Guest5'];
$to .= ", ".$_POST['Guest6'];
$to .= ", ".$_POST['Guest7'];
$to .= ", ".$_POST['Guest8'];
$to .= ", ".$_POST['Guest9'];
$to .= ", ".$_POST['Guest10'];

// Message Body
$message = "
		You have been invited to ".$from."'s event!<br />
		Here are some of the details...<br />
		Date: ".$_POST['Date']."<br />
		Time: ".$_POST['Time']."<br />
		Location: ".$_POST['Location']."<br />
		<br />
		Comments: $Comments
	";
					
	$from = "$from";
	$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
	$headers .= "From: Invitation <$hostEmail>\r\n";

	$send = mail($to,$subject,$message,$headers);
	
	if($send){
		echo
			$to."<br />".
			$from."<br />".
			$subject."<br />".
			$date."<br />".
			$event."<br />".
			$message
		;
	}

}
?>

<input type=hidden name="subject" value="Invitation"/>    

Host (your name): <input type=text name="Name"/>
<br /><br />
Host email: <input type=email name="hostEmail"/>
<br /><br />
Event Date (dd/mm/yy): <input type=date name="Date"/>
<br /><br />
Event Time: <input type=time name="Time"/>
<br /><br />
Location: <input type=text name="Location"/>
<br /><br />
Extra Comments: <input type=text name="Comments"/>
<br /><br />

Guest 1: <input type=email name="Guest1"/>
<br /><br />
Guest 2: <input type=email name="Guest2"/>
<br /><br />
Guest 3: <input type=email name="Guest3"/>
<br /><br />
Guest 4: <input type=email name="Guest4"/>
<br /><br />
Guest 5: <input type=email name="Guest5"/>
<br /><br />
Guest 6: <input type=email name="Guest6"/>
<br /><br />
Guest 7: <input type=email name="Guest7"/>
<br /><br />
Guest 8: <input type=email name="Guest8"/>
<br /><br />
Guest 9: <input type=email name="Guest9"/>
<br /><br />
Guest 10: <input type=email name="Guest10"/>

<input type="submit" name="sendInvite" value="Send Invite"/>
[/php]

Thank you SOOOO much, you are so talented and kind to help others. I will look into this in depth and learn from it. Thanks again…

I will see if it works and if there’s anything else that it needs

It’s not a problem. I enjoy doing this stuff so when I can help a fellow coder (or someone that just needs helps with code) I do what I can. Please do ask if there is anything else you need!

It worked perfectly! :smiley:
Now I just need to design it, which is what I do :slight_smile:

A couple things. How would I make it so that the original form didn’t show on the next page after submitting it?
Would that be by putting the html on one page and the php on it’s own, and doing form action=“invitation.php” or something? Am I close?
I’d like the confirmation page to show only the email content, which i will design it as a colorful invitation, and omit the email addresses, host name and subject at the top if possible

like this?

[php]
if(isset($_POST[‘sendInvite’]))
{

$from = $_POST['Name'];				// Who the email is from
$hostEmail = $_POST['hostEmail'];	// Host's email
$subject = $_POST['subject'];		// Subject line
$date = $_POST['date'];				// Event's date
$event = $_POST['event'];			// Name of the event
$Comments = $_POST['Comments'];		// Extra comments
	
/* 
	This builds the invite list
*/
$to = $_POST['Guest1'];
$to .= ", ".$_POST['Guest2'];
$to .= ", ".$_POST['Guest3'];
$to .= ", ".$_POST['Guest4'];
$to .= ", ".$_POST['Guest5'];
$to .= ", ".$_POST['Guest6'];
$to .= ", ".$_POST['Guest7'];
$to .= ", ".$_POST['Guest8'];
$to .= ", ".$_POST['Guest9'];
$to .= ", ".$_POST['Guest10'];

// Message Body
$message = "
		You have been invited to ".$from."'s event!<br />
		Here are some of the details...<br />
		Date: ".$_POST['Date']."<br />
		Time: ".$_POST['Time']."<br />
		Location: ".$_POST['Location']."<br />
		<br />
		Comments: $Comments
	";
					
	$from = "$from";
	$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
	$headers .= "From: Invitation <$hostEmail>\r\n";

	$send = mail($to,$subject,$message,$headers);
	
	if($send){
		echo
			$to."<br />".
			$from."<br />".
			$subject."<br />".
			$date."<br />".
			$event."<br />".
			$message
		;
	}

}else
{
?>

<input type=hidden name="subject" value="Invitation"/>    

Host (your name): <input type=text name="Name"/>
<br /><br />
Host email: <input type=email name="hostEmail"/>
<br /><br />
Event Date (dd/mm/yy): <input type=date name="Date"/>
<br /><br />
Event Time: <input type=time name="Time"/>
<br /><br />
Location: <input type=text name="Location"/>
<br /><br />
Extra Comments: <input type=text name="Comments"/>
<br /><br />

Guest 1: <input type=email name="Guest1"/>
<br /><br />
Guest 2: <input type=email name="Guest2"/>
<br /><br />
Guest 3: <input type=email name="Guest3"/>
<br /><br />
Guest 4: <input type=email name="Guest4"/>
<br /><br />
Guest 5: <input type=email name="Guest5"/>
<br /><br />
Guest 6: <input type=email name="Guest6"/>
<br /><br />
Guest 7: <input type=email name="Guest7"/>
<br /><br />
Guest 8: <input type=email name="Guest8"/>
<br /><br />
Guest 9: <input type=email name="Guest9"/>
<br /><br />
Guest 10: <input type=email name="Guest10"/>

<input type="submit" name="sendInvite" value="Send Invite"/>
<?php } ?>

[/php]

That is exactly what you need to do.

You may show only what the message of the email being sent will be if after you send the email you do this

[php]

$send = mail($to,$subject,$message,$headers);

	if($send){
		echo $message;
	}

[/php]

That will show only the body of the email being sent.

k sorry, mdalkhe you’re saying paste that line in? or…
exactly what i need to do is…? what i had said about the separate html and php files? or just use that line?

Oops ok I swapped that line out for the old one, and it removed the info i wanted out (emails, subject etc)
but the form is still on the bottom of the validation page. so do i need to put the form on the separate html page then? is that what you meant? and it will be ok if i put in it? thanks so much, almost there!

my code remove the form from being shown after submitted take a look and modify according to your need

Use two seperate files to (one for html, the other for mailer).

for displaying only the message of the email, in your mailing script(PHP) you’ll want to echo $message in the body of the page…

This would be your Email sent success (or failed to send) page…

[php]<?php
if(isset($_POST[‘sendInvite’]))
{

$from = $_POST['Name'];				// Who the email is from
$hostEmail = $_POST['hostEmail'];	// Host's email
$subject = $_POST['subject'];		// Subject line
$date = $_POST['date'];				// Event's date
$event = $_POST['event'];			// Name of the event
$Comments = $_POST['Comments'];		// Extra comments
	
/* 
	This builds the invite list
*/
$to = $_POST['Guest1'];
$to .= ", ".$_POST['Guest2'];
$to .= ", ".$_POST['Guest3'];
$to .= ", ".$_POST['Guest4'];
$to .= ", ".$_POST['Guest5'];
$to .= ", ".$_POST['Guest6'];
$to .= ", ".$_POST['Guest7'];
$to .= ", ".$_POST['Guest8'];
$to .= ", ".$_POST['Guest9'];
$to .= ", ".$_POST['Guest10'];

// Message Body
$message = "
		You have been invited to ".$from."'s event!<br />
		Here are some of the details...<br />
		Date: ".$_POST['Date']."<br />
		Time: ".$_POST['Time']."<br />
		Location: ".$_POST['Location']."<br />
		<br />
		Comments: $Comments
	";
					
	$from = "$from";
	$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
	$headers .= "From: Invitation <$hostEmail>\r\n";

	$send = mail($to,$subject,$message,$headers);

}
?>

Email Sent

You’re invite was successfully sent!



<?php if($send){ echo $message; } else { echo "Message not sent"; } ?> [/php]

Thanks wilson, i’m still trying to pick out what is different in yours to modify mine. What exactly is added that makes the form disappear? Is it the else?

wilson382 you did it, thank you so much!
i found the thing it was missing!
so kind and talented you are :smiley:

thanks everyone, you rock!

i put an else statement after the if statement that mdahlike included so i just extended

[php]
if (isset(blahblah))
{

//php codes

}else// i added the else
{//i added the bracket and the php closing tag below it
?>
display form here
}

<?php }//i added this ?>

[/php]

tht’s how it goes

how would i insert an image in between variables in the confirmation page

and how do i style the email received?

Sponsor our Newsletter | Privacy Policy | Terms of Service