Solved

PHP3 and session handling

Posted on 2000-04-19
6
271 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

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…
Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

862 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

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now