session handling

Ask about general coding issues or problems here.

Moderators: egami, macek, gesf

Post Reply
New php-forum User
New php-forum User
Posts: 7
Joined: Sun Sep 29, 2002 9:36 am

Wed Oct 02, 2002 12:25 am

I have a problem with session handling

I have a form from like this
<form action="save.php">
<input type="text" name="name">
<input type="text" name="address">
<input type="text" name="phoneNo">
<input type="submit" >

and in save.php
I am using code like








The problem is that when user fill the form second time then this code does not updates the variables with new values,

Any suggestion how to over write the old values with new one.

Thank you very much in advance


Wed Oct 02, 2002 2:33 am

I think you're "register_globals" setting is set to "on" so giving the form-fields the same name as you're session name's can be a bit of a juggle.

If you change the form-field-names to something like "frm_fieldname" you can see the difference in you're script, otherwise one of the two will be overwritten by the other.

once the names are different you can simply change you're session-variable by assigning it the new variable (wich came from the form).
You can then also skip the unregistering en registering of the variable.

form example:

Code: Select all

<input type="text" name="frm_name"> 

re-assigning value:

Code: Select all

$name = $frm_name;

where $name is allready registered ofcourse.

Greetz Daan

Post Reply