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]
session handling
Moderators: egami, macek, gesf
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:
re-assigning value:
where $name is allready registered ofcourse.
Greetz Daan
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