/    Sign up×
Community /Pin to ProfileBookmark

[RESOLVED] Multiple form pages

hey everyone, i am looking to create a signup page that uses 6 different form pages that i created all individually. I was wondering if there was a way for me to use the same page and in a way just reload the “frame” <– not really a frame, where the form was located. right now i am using the same header page and in the body just using <?php include ‘blahblah.php’; ?> and posting to a new .php page that is just the same header including a different form in the body. if this makes no sense please let me know and i will try to elaborate
thanks in advance

to post a comment
PHP

13 Comments(s)

Copy linkTweet thisAlerts:
@NightShift58Jan 04.2007 — That would work.

You can do it that way or you could have all your forms on a single page, using $_GET variables to keep track of which step you are on. Something like:[code=php]<?php
IF (!isset($_GET['step'])) :
print "<form name='form1' action='{$_SERVER['PHP_SELF']}?step=2' method='post'>";
...
...
print "</form>";
ELSEIF ($_GET['step'] == 2) :
print "<form name='form2' action='{$_SERVER['PHP_SELF']}?step=3' method='post'>";
...
...
print "</form>";
ELSEIF ...[/code]
The advantage would be to have a single page for all your code instead of 6.
Copy linkTweet thisAlerts:
@NickG21authorJan 04.2007 — after you print out the <form> things could i just use an include statement before the elseif in order to display the forms i had already created?
Copy linkTweet thisAlerts:
@NightShift58Jan 04.2007 — Yes, that too.

If you're going to use includes, I think it would be more "elegant" to have at least one page when you control the flow of things. In that case, however, I would put the "<form> things" in the included page, where they logically belong.[code=php]<?php
IF (!isset($_GET['step'])) :
include "page1.php";
ELSEIF ($_GET['step'] == 2) :
include "page2.php";
ELSEIF ... [/code]
Copy linkTweet thisAlerts:
@NickG21authorJan 05.2007 — in order to see is the step is set to 1, 2, 3 etc... would it be easiest to just pass a hidden variable when the "Next" button is pressed that is named "step" with a value of 1, 2, 3 etc....? if these steps seem rediculous i apologize im pretty new to this stuff

thank you for your help
Copy linkTweet thisAlerts:
@NightShift58Jan 05.2007 — "Hidden" would work, too. Probably better than $_GET (but change the checks from $_GET to $_POST...)

Or this:[code=php]<?php
$REFpage = basename($_SERVER['HTPP_REFERER']);
IF ($REFpage == "page1.php") :
include "page2.php";
ELSEIF ($REFpage == "page2.php") :
include "page3.php";
ELSEIF ...
...
ELSE : //default
include "page1.php";
ENDIF;
[/code]
Copy linkTweet thisAlerts:
@NickG21authorJan 05.2007 — i have gotten my code to be
[CODE] <?php
IF (!isset($_POST['step'])) {
include "ListInfo.php";}
ELSEIF ($_POST['step'] == 2){
include "OptServices.php";}
ELSEIF ($_POST['step'] == 3){
include "ContInfo.php";}
ELSEIF ($_POST['step'] == 4){
include "BillInfo.php";}
ELSEIF ($_POST['step'] == 5){
include "Survey.php";}
ELSEIF ($_POST['step'] == 6){
include "Terms.php";
}
?>[/CODE]

in order to get the forms to all display. that works great but when i put

<?php

session_start();

foreach($_POST as $key => $var) {

$_
SESSION[$key] = $var;

}

?>

in either the main form to display them or the individual forms themselves to keep the same session and store the variables i get the error:

Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /home/web/.../headerImage.php:8) in /home/web/.../ListInfo.php on line 3

i wonder if i could just include it either the main page or first page and then check in the others to see if a session exists and if so continue writing the posted variables?
Copy linkTweet thisAlerts:
@NightShift58Jan 05.2007 — You can't have [b]session_start()[/b] in both the main page AND in the included pages. Remember that the included pages become "part" of the including page and just as you couldn't use [b]session_start()[/b] twice in one page, you can't use it in the main and in the included page.

I would put[code=php]<?php
session_start();
foreach($_POST as $key => $var) {
$_SESSION[$key] = $var;
}
?>[/code]
only in the main page.
Copy linkTweet thisAlerts:
@NickG21authorJan 05.2007 — that is what i tried at first and received the error:

Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /home/web/.../headerImage.php:8) in /home/web/.../headerImage.php on line 106

so i tried on all the other pages and received the previous error.
Copy linkTweet thisAlerts:
@NightShift58Jan 05.2007 — Something else is generating HTML headers. Can you post the code of the included page where this is happening?
Copy linkTweet thisAlerts:
@NickG21authorJan 05.2007 — i figured out what was going on with the posting of the data, but i am still unable to transmit the data from the last page to an e-mail. this seems like it is being way more complicated than it should be.

i know that it is because formmail.php only receives the information that is posted on the page where the action="formmail.php" and that is my last form. is there a way to post all of the saved variables as well as the last one submitted? i think that making them all into hidden fields would work but when i tried that using
[CODE]foreach($_SESSION as $key => $value)
{
echo "<input type='hidden' value='" . $value . "' name='value" .
$key . "'>";
}[/CODE]

i still only receive the last posted item on the last form.

sorry if this is an inconvenience but you're help is definitely very appreciated

also if you would like to check these forms out working go to www.netatlantic.com/test/nickgirard/headerImage.php

I put in an echo of all the variables at the bottom of the pages as they go through to show that they are being stored but aren't sent in the end
Copy linkTweet thisAlerts:
@NightShift58Jan 05.2007 — The logic - converting the session variables to hidden post variables - is correct. But... you need to do it in the right place/page. So, it depends on when "formmail.php" is called.

The conversion, session-to-post-hidden, has to take place in the last <form> before "formmail.php" is called -> or, in your case, whatever page is included in "Step 6", which should be "Terms.php".

Be certain to run the loop between <form> and </form>...
Copy linkTweet thisAlerts:
@NickG21authorJan 05.2007 — that works perfect, I am going to try and implement my mailing templates with that information. i want to thank you for your time and everything you helped me out with, this willl definitely help me in the future

thanks again
Copy linkTweet thisAlerts:
@NightShift58Jan 05.2007 — You're welcome.
×

Success!

Help @NickG21 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.8,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...