Solved

PHP3 and session handling

Posted on 2000-04-19
6
280 Views
Last Modified: 2008-03-06
I am developing a Portal job application. There are 4 forms in that. I want to carry the information from all the forms to the last form. There when I click submit I have to update the local database and post to other sites. How can I carry the information from one form to another until the last form. BEcause there are 50 fields to be carried to the final form. Can I use cookies or session. Please help me in solving the problem. I'm new to PHP, using PHP ver3.0
0
Comment
Question by:balasundaram
6 Comments
 
LVL 8

Expert Comment

by:us111
ID: 2730551
Good question. I don't know if I have the answer.
I think that your browser can stored 4k for a cookie. If it's enough
for 50 fields, use cookies. But I know people who don't accept cookies.

<? setcookie("TestCookie[]","Test Value"); ?>

For native session, use php4.0
otherwise with php3 use phplib which allows session
http://phplib.netuse.de

0
 

Expert Comment

by:mrvithan
ID: 2732888
Welll.... It has so many solution to do ...
1. you might use <input type="hidden"> to keep a field data on a page to next page and go on...for example

page1 : <intput type="text" name="firstname" value="">

page 2: <input type="hidden" name="firstname" value="<?php echo $firstname ?>">
            <input type="text" name="lastname" value="">

page 3: <input type="hidden" name="firstname" value="<?php echo $firstname ?>">
            <input type="hidden" name="lastname" value="<?php echo $lastname ?>">
            <input type="text" name="age" value="">

With this solution you don't need to deal with session but your page is non-sense.

2: If you really want to use session, it goes through as same as the solution 1. for example

page1 : session_start()
            <intput type="text" name="firstname" value="">

page 2: session_register('firstname')
            <input type="text" name="lastname" value="">

page 3: session_register('firstname')
            session_register('lastname')
            <input type="text" name="age" value="">

someone else might has a better coding
but I suggest you to do this 'cause you willn't get any problem with data that keep in session variable isn't up-to-date


0
 
LVL 2

Expert Comment

by:freshmeat
ID: 2732915
use php lib
0
Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

 

Accepted Solution

by:
alexdg earned 100 total points
ID: 2742727
THE BEST SOLUTION IMHO =)

name all your form fields like:

<input type="" name="form[_REAL_FIELD_NAME_]" value="">

Later, to carry all the form elemnts on other pages use this code:

<?
reset($form);
while(list($value, $key) = each($form)) {
?>
<input type="hidden" name="form[<? echo $key ?>]" value="<? echo $value ?>">
<? } ?>

This will carry all fields you entered on previous pages as hidden form fields on future pages.
0
 

Expert Comment

by:Agent_Neo
ID: 2865458
On that last line why do you do this?
?>
<input type="hidden" name="form[<? echo $key ?>]" value="<? echo $value ?>">
<? } ?>

Why not just this? :)

print "<input type=\"hidden\" name=\"$form[$key]\" value=\"$value\">\n";

FULL CODE:

<?
reset($form);
while(list($value, $key) = each($form)) {

     print "<input type=\"hidden\" name=\"$form[$key]\" value=\"$value\">";

}
?>
0
 

Expert Comment

by:Agent_Neo
ID: 2865463
Opps :) change $form to just "form"
0

Featured Post

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question