Solved

PHP3 and session handling

Posted on 2000-04-19
6
259 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
Comment Utility
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
Comment Utility
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
Comment Utility
use php lib
0
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 

Accepted Solution

by:
alexdg earned 100 total points
Comment Utility
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
Comment Utility
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
Comment Utility
Opps :) change $form to just "form"
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
The viewer will learn how to count occurrences of each item in an array.
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…

771 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

10 Experts available now in Live!

Get 1:1 Help Now