Solved

PHP3 and session handling

Posted on 2000-04-19
6
305 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Why Off-Site Backups Are The Only Way To Go

You are probably backing up your data—but how and where? Ransomware is on the rise and there are variants that specifically target backups. Read on to discover why off-site is the way to go.

 

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

Don't Cry: How Liquid Web is Ensuring Security

WannaCry is just the start. Read how Liquid Web is protecting itself and its customers against new threats.

Question has a verified solution.

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

Generating table dynamically is the most common issue faced by php developers.... So it seems there is a need of an article that explains the basic concept of generating tables dynamically. It just requires a basic knowledge of html and little maths…
Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
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 look for a specific file type in a local or remote server directory using PHP.

691 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