sending an email at the same time as setting the form action to another page – PHP

  php

Q(Question):

Hi there,

Beg of your forgiveness if this is too basic or the question has already been answered somewhere… I’m still learning my way around php and this site.

I have a form on page 1 which is sent to be displayed on page 2. Is there a way to do this while also sending an email to me with the information that was submitted? I know how to do both individually, just not simultaneously, and google isn’t helping (wait, why am I still googling now that I found bytes?)

Thanks in advance… you guys are the best.

~ Deb

A(Answer):

Just do it on page 2 with the information coming from page one.

A(Answer):

Yes, I thought about that as well. The reason I’d like to do it this way is this:

On page 1 they enter contact information.
On page 2 they enter payment information (there’s a reason for separating them).

If, for some reason, they don’t complete the payment information on page 2, I’d like to have their contact information so that I can email them to follow up and answer any questions they may have.

So, that takes us back to the original question. Is it possible?

Thanks bunches, if I was there I’d give you a cupcake with chocolate sprinkles.

A(Answer):

The second page can email you the data from the first page whether or not they actually submit the form on the second page.

The logic being:


## Page 1
<form action="page2" method="post">
<input type="text" name="contactData" />
</form>
## Page 2
<?php
mail ("to@example.com" , "Contact data" , $_POST['contactData']);
?>
<form action="page3" method="post">
<input type="text" name="paymentData" />
</form>
## Page 3
<?php
// This is where you would process the payment data.
?>

This is obviously not a working example, but you get the point?

A(Answer):

OMG you are just awesome.

Yes, I got it to work with one of the entries… but there are 6 entries… how do I get all six of them? I’ve experimented a bit with no luck.

A(Answer):

I figured it out! All I usually need is someone to point me in the right direction. =)

Thanks bunches!

~ Deb

A(Answer):

Glad you got it working 🙂

LEAVE A COMMENT