Page 1 of 1

Editing/re-assigning SESSION values

Posted: Tue Jul 17, 2007 5:22 am
by aceconcepts
Hi,

I'm actually quite confused by this issue.

I have two forms:

Form 1 is a registration form where a user may enter their details (e.g. first name and last name).

Form 2 is a 'review' page where the user can edit/confirm the details they entered in Form 1.

Once Form 1 is 'posted' I set SESSION variables equal to the 'posted' form field values.

In Form 2 I use the SESSION variable values to populate the fields. From here the user can edit their details.

However, when I try to edit a text field and append an additional string AFTER a whitespace the SESSION value is not updated. When I simply append a string without a whitespace, the SESSION value is updated.

For your information:

The SESSION values are re-assigned once Form 2 is 'posted'.

Each form field in Form 2 has a 'Value' equal to an appropriate SESSION variable.

Any suggestions?

Posted: Tue Jul 17, 2007 5:36 am
by volka
aceconcepts wrote:However, when I try to edit a text field and append an additional string AFTER a whitespace the SESSION value is not updated. When I simply append a string without a whitespace, the SESSION value is updated.
An input/text element and no quotes around the value of the attribute value ?

Posted: Tue Jul 17, 2007 5:39 am
by aceconcepts
This is my text input element:

Code: Select all

echo "<input class=\"reg\" type=\"text\" name=\"aFirstName\" value=" . $_SESSION["dbFirstName"] . ">

Posted: Tue Jul 17, 2007 5:49 am
by volka
exactly, the browser get's it without quotes. Open your browser's source view. You will find something like

Code: Select all

<input class="reg" type="text" name="aFirstName" value=foo bar>
aceconcepts wrote:echo "<input class="reg" type="text" name="aFirstName" value=" . $_SESSION["dbFirstName"] . ">
You've added quotes for all other attributes but not for value.

Posted: Tue Jul 17, 2007 5:56 am
by aceconcepts
Sorry I'm being a bit dumb, what do I need to do?

I've tried adding in quotes but an error returns.

Posted: Tue Jul 17, 2007 6:02 am
by volka

Code: Select all

echo '<input class="reg" type="text" name="aFirstName" value="', $_SESSION["dbFirstName"], '" />';
If $_SESSION["dbFirstName"] can contain double-quotes, you have to replace them

Code: Select all

echo '<input class="reg" type="text" name="aFirstName" value="', htmlentities($_SESSION["dbFirstName"]), '" />';

Posted: Tue Jul 17, 2007 6:05 am
by aceconcepts
Ok sorted it now.

Sorry for my stupidity. I find that when I look at the same piece of code for too long I cant notice anything at fault haha

Anyway thanks for your help and certainly your patience.

Cheers