Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
0

Carrying $_POST vars to next page

Engaged ,
Jun 23, 2008 Jun 23, 2008

Copy link to clipboard

Copied

I have a form processing page, which uses the $_POST variables to insert a record - simple.

What I am trying to do is to use these same $_POST variables in the next page (after submit) to create an e-mail which will then be used to verify that the e-mail address is true.

I am fairly new at this and I'm not sure how to do this....

I thought by using the following, I could re-capture the variables and use them on the next page, but obviously not.

<?php
$username=$_POST['username'];
$postgroupcode=$_POST['groupcode'];
$email=$_POST['email'];
$title=$_POST['title'];
$firstname=$_POST['firstname'];
$lastname=$_POST['lastname'];
?>

Does this mean I have to put the mail function in the same page as the record insert function?
TOPICS
Server side applications

Views

515
Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jun 23, 2008 Jun 23, 2008

Copy link to clipboard

Copied

Why go to another page? Just place the email code on the form processing
page.

--
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs, Tutorials & Resources
==================


"RichardODreamweaver" <webforumsuser@macromedia.com> wrote in message
news:g3otb8$er9$1@forums.macromedia.com...
>I have a form processing page, which uses the $_POST variables to insert a
> record - simple.
>
> What I am trying to do is to use these same $_POST variables in the next
> page
> (after submit) to create an e-mail which will then be used to verify that
> the
> e-mail address is true.
>
> I am fairly new at this and I'm not sure how to do this....
>
> I thought by using the following, I could re-capture the variables and use
> them on the next page, but obviously not.
>
> <?php
> $username=$_POST['username'];
> $postgroupcode=$_POST['groupcode'];
> $email=$_POST['email'];
> $title=$_POST['title'];
> $firstname=$_POST['firstname'];
> $lastname=$_POST['lastname'];
> ?>
>
> Does this mean I have to put the mail function in the same page as the
> record
> insert function?
>

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jun 23, 2008 Jun 23, 2008

Copy link to clipboard

Copied

This is a good question. Even though his objective might be solved in other ways. It would be great to get an answer to his original inquiry.

I am also interested in using a posted variable from a form on other pages of the site.

The form posts to one page (the receipt page). You can use the form variables easily on that page (the receipt page) by creating a form variable and dragging it to where you want it on the page.

BUT, how can you use this information on other pages in the site? What type of "variable" would you create and how?

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jun 23, 2008 Jun 23, 2008

Copy link to clipboard

Copied

Post from page A to page B. Page B loads hidden form fields with the
information posted from Page A. To navigate away from Page B, you click a
button which submits the hidden fields to Page C. That's typically how it's
done.

Alternately, you could post to Page B, and include those posted data in URL
variables, or cookies, or Session variables when you link to Page C.

Like that.

--
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs, Tutorials & Resources
==================


"EviePhillips" <webforumsuser@macromedia.com> wrote in message
news:g3pbs0$hu$1@forums.macromedia.com...
> This is a good question. Even though his objective might be solved in
> other
> ways. It would be great to get an answer to his original inquiry.
>
> I am also interested in using a posted variable from a form on other pages
> of
> the site.
>
> The form posts to one page (the receipt page). You can use the form
> variables
> easily on that page (the receipt page) by creating a form variable and
> dragging
> it to where you want it on the page.
>
> BUT, how can you use this information on other pages in the site? What
> type
> of "variable" would you create and how?
>

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jun 24, 2008 Jun 24, 2008

Copy link to clipboard

Copied

EviePhillips wrote:
> BUT, how can you use this information on other pages in the site? What type
> of "variable" would you create and how?

Use a session variable.

Put this at the beginning of the page:

session_start();

Then capture the $_POST variable and assign it to a $_SESSION variable
like this:

if (isset($_POST['variableName'])) {
$_SESSION['variableName'] = $_POST['variableName'];
}

If your server uses magic quotes (run phpinfo() and see if
magic_quotes_gpc is "On"), change the code above to this:

if (isset($_POST['variableName'])) {
$_SESSION['variableName'] = stripslashes($_POST['variableName']);
}

You can now access $_SESSION['variableName'] in any page that begins
with session_start().

--
David Powers, Adobe Community Expert
Author, "The Essential Guide to Dreamweaver CS3" (friends of ED)
Author, "PHP Solutions" (friends of ED)
http://foundationphp.com/

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Jun 24, 2008 Jun 24, 2008

Copy link to clipboard

Copied

Perfect!

I can use both these techniques. Both answers are ideal.

Murray - I will put the mail function on the post page as you suggested.

David - thanks for this too - I can now pass the variable to the next page where it will show the user what is being sent and why. (My server does use magic quotes)

Thanks Guys.

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Jun 24, 2008 Jun 24, 2008

Copy link to clipboard

Copied

OK - don't know what I'm doing wrong...

I've put Davids script in the form processing page and followed the advice for the 2nd page but it isn't carrying the variable.

I've tried the magic quotes and non magic quotes solutions.

Code attached

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jun 24, 2008 Jun 24, 2008

Copy link to clipboard

Copied

RichardODreamweaver wrote:
> I've put Davids script in the form processing page

No you didn't. Read what I wrote again.

Put this at the beginning of the page:

session_start();

You put it at the end of the script on the first page.

--
David Powers, Adobe Community Expert
Author, "The Essential Guide to Dreamweaver CS3" (friends of ED)
Author, "PHP Solutions" (friends of ED)
http://foundationphp.com/

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jun 24, 2008 Jun 24, 2008

Copy link to clipboard

Copied

.oO(Murray *ACE*)

>Post from page A to page B. Page B loads hidden form fields with the
>information posted from Page A. To navigate away from Page B, you click a
>button which submits the hidden fields to Page C. That's typically how it's
>done.

That's the worst way for doing it. You're wasting a lot of bandwidth
with these ping-pong data transfers and would have to revalidate the
data over and over again, because users can always manipulate it.

Additionally it would always require a button instead of a simple link
to navigate between the pages.

>Alternately, you could post to Page B, and include those posted data in URL
>variables, or cookies, or Session variables when you link to Page C.

Sessions are the correct and most efficient way for this, because it's
exactly what sessions are made for.

Micha

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Jun 25, 2008 Jun 25, 2008

Copy link to clipboard

Copied

LATEST
David - my apologies, I will lift the session start to the start! (this evening).

Micha - If I'm using a simple redirect in the insert function, do I need any additional buttons other then the submit??

With David's solution, I only need 2 pages. On the 2nd page, the user will be encouraged to close the window and follow an <aref> URL from the mail which is sent.

As Murray mentioned to start with, it would have been easier to put the mail function in the first post page, but I was getting header issues that I couldn't resolve. (Headers already sent blah de blah)

Thanks for your help guys. This is probably the most critical part of the website and it needs to be right!

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines