Sam
Sam

Reputation: 111

Display users email address on form thank-you page

I'm creating a forms thank-you page, the thank-you page will read:

<p>An activation link is being sent to your email address <b>[email protected]</b>. If you do not receive it, please check your spam filter. </p>

I want their email address to appear on the thank-you page (where [email protected] shows above).

What code do I need to put, to show this? The form is coded with PHP and can be seen at:

http://www.workbooks.com/sign-up/free-edition

Many thanks,

Sam

Upvotes: 0

Views: 198

Answers (4)

HeatherEMSL
HeatherEMSL

Reputation: 285

There are answers with suggestions to output directly from $_POST/$_GET but that would be unsafe, particularly if you don't know how well validated the user input has been up to that point. Rule 1 of dealing with user input - it is dangerous and you should never trust it.

At the very least run it through a basic PHP string sanitization function like filter_input. So something like:

<p>An activation link is being sent to your email address <b><?php echo filter_input(INPUT_POST,'email',FILTER_VALIDATE_EMAIL) ; ?></b>. If you do not receive it, please check your spam filter.</p>

If the input was not a valid email address you'll get "false" coming out there but it's infinitely better than allowing the user to put whatever they want on the page.

Upvotes: 1

Rohil_PHPBeginner
Rohil_PHPBeginner

Reputation: 6080

Its is very simple.You need to just add <?php echo $_POST['email'] ; ?> So it will print the Email Address.

So according to your answer it will be something like this :

<p>An activation link is being sent to your email address <b><?php echo $_POST['email'] ; ?></b>. If you do not receive it, please check your spam filter. </p>

Note: You need to have thanks file in with .php extension.

Upvotes: 0

Ole Haugset
Ole Haugset

Reputation: 3797

simply echo the posted form value:

<p>An activation link is being sent to your email address <b><?php echo $_POST['email'] ; ?></b>. If you do not receive it, please check your spam filter. </p>

This example is based on the fact that the input field for email has the name "email"

Upvotes: 1

pavel
pavel

Reputation: 27092

E-mail address is in POST/GET, depending on method you are using to send a form.

Upvotes: 1

Related Questions