visitor (0 QPoints)
  • FR
  • EN
  • NL
  • DE
  • ES
315 experts, 1193 registered users, 1659 questions already answered
European Experts Exchange, the very best site for high-quality IT solutions

New Improved Search!

 


05/10/2011 1h30 : Steve Jobs is dead, the father of Apple ][ is gone, we are all orphaned.

Languages :: PHP :: multi-page FORM in PHP ?


By: Bernard France  Date: 31/12/2004 09:19:45  English French  Points: 20 Status: Answered
Quality : Excellent
Dears,

I had this brilliant idea to split a long form on my site re-design into four pages and am now struggling with the how-to. I was told that this was "easily" done in php.

I did some search, here and on google, and found a tutorial on codewalkers.com (http://codewalkers.com/tutorials.php?show=28&page=1). But since I am a serious php newbie I could not figure out how to use this.

Here is what I would like to ask for (and forgive me if this is very basic, I just started out with PHP Visual Quickstart Guide; it's kinda embarassing :-) :
1. Do you have a recommendation on what I should use? And can you guide me on how to use it?
2. If I use the material from the above link, could you help me figure out where to put what? I always love learning new stuff, but now I'm lost.
By: VGR Date: 31/12/2004 09:33:43 English  Type : Answer
Yes this is really easy to do.

You've two solutions, equially viable :
1)use $_SESSION variables. Once you pass the form to the next page just set the values to $_SESSION variables ; this requires only a session_start() call at the top of every page sharing the session's data
2) use hidden fields in your FORM, when passing them from page to page (in fact, from FORM to FORM)


Quite automagically, if you put upon reception all variables from a FORM in a given array named $thevars[] and then do this when outputting the next page's FORM :

with this kind of code snippet :

echo <<<EOS <FORM ...> <input... EOS; foreach ($thevars as $var=>$val) echo "<input type=hidden name='$var' value='$val'>"; echo "</FORM>\n";



you'll end up with a nice & complete $thevars[] containing all FORMS' data, ready to be interpreted by the last script.

In case you ask yourself "how to convert my HTML pages into PHP scripts without passing 4 hours on that silly task?", here's the answer :
1) just put this in each HTML page
1a) on top :

<?php // // script machin-chose // // history section // echo <<<EOFILE


1b) on bottom :

EOFILE; ?>



2) rename all files into .php unless you configured your webserver for accepting extensions .htm, .html as PHP scripts (via the "AddType php" entry)
By: Bernard Date: 10/01/2005 09:26:47 French English  Type : Comment
very nice and clean solution, except perhaps for the PHP parsing of HTML files. That's the easy solution ("la voie large" ;-)

Do register to be able to answer

EContact
browser fav
page generated in 343.540910 milliseconds

Why Google AdSense ads ?

compteur
 Ranking-Hits PageRank for this page