Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => General

session handling

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

session handling

Postby qadeerbk » 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" >
</form>

and in save.php
I am using code like

<?PHP

session_start();

if(session_is_reqistered(name))
session_unregister(name)

if(session_is_reqistered(address))
session_unregister(address)

if(session_is_reqistered(phoneNo))
session_unregister(phoneNo)

session_register(name,address,phoneNo);


?>

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
[/b]
qadeerbk
New php-forum User
New php-forum User
 
Posts: 7
Joined: Sun Sep 29, 2002 9:36 am

Postby DoppyNL » 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
session_start();
$name = $frm_name;

where $name is allready registered ofcourse.

Greetz Daan
DoppyNL
 


Return to PHP coding => General

Who is online

Users browsing this forum: Google [Bot], landi and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.