Connecting Tech Pros Worldwide Help | Site Map

php session failure

 
LinkBack Thread Tools Search this Thread
  #1  
Old August 21st, 2007, 07:55 PM
GarryJones
Guest
 
Posts: n/a
Default php session failure

In a php session I have set up a user can input several hundred values
on a form.

I then show the user what he or she has entered on a preview page
which he or she can then click ok or cancel.

On clicking cancel the user should be backed using this code

<td>
<div align="center">
<input type="Submit" value = "Continue">
&nbsp;
<input type="button" value="Cancel" onClick="history.back()">
</div>
</td>

I have used this before at it worked. However it now returns the user
to the previous page (form entry), but now all the values are empty.
Annoying if the user just made one simple mistake in the several
hundred entries they wanted to correct.

Any ideas what I am doing wrong?

Any other tricks to acheive this?

Garry Jones
Sweden


  #2  
Old August 21st, 2007, 08:15 PM
ELINTPimp
Guest
 
Posts: n/a
Default Re: php session failure

On Aug 21, 3:48 pm, GarryJones <mor...@algonet.sewrote:
Quote:
In a php session I have set up a user can input several hundred values
on a form.
>
I then show the user what he or she has entered on a preview page
which he or she can then click ok or cancel.
>
On clicking cancel the user should be backed using this code
>
<td>
<div align="center">
<input type="Submit" value = "Continue">
&nbsp;
<input type="button" value="Cancel" onClick="history.back()">
</div>
</td>
>
I have used this before at it worked. However it now returns the user
to the previous page (form entry), but now all the values are empty.
Annoying if the user just made one simple mistake in the several
hundred entries they wanted to correct.
>
Any ideas what I am doing wrong?
>
Any other tricks to acheive this?
>
Garry Jones
Sweden
Do you have session_start() on top of both pages?
Post a snippit of offending HTML code of the form entry page, for now,
please.

  #3  
Old August 21st, 2007, 10:55 PM
Jerry Stuckle
Guest
 
Posts: n/a
Default Re: php session failure

GarryJones wrote:
Quote:
In a php session I have set up a user can input several hundred values
on a form.
>
I then show the user what he or she has entered on a preview page
which he or she can then click ok or cancel.
>
On clicking cancel the user should be backed using this code
>
<td>
<div align="center">
<input type="Submit" value = "Continue">
&nbsp;
<input type="button" value="Cancel" onClick="history.back()">
</div>
</td>
>
I have used this before at it worked. However it now returns the user
to the previous page (form entry), but now all the values are empty.
Annoying if the user just made one simple mistake in the several
hundred entries they wanted to correct.
>
Any ideas what I am doing wrong?
>
Any other tricks to acheive this?
>
Garry Jones
Sweden
>
As you've found, history.back() is not foolproof. And what if they have
javascript disabled?

It's harder, but put the cancel button in a form. In that form have the
values as hidden fields, i.e.


<form action="/entrypage.php" method="post">
<input type=hidden name="value1" value="<?php echo $value1;%>
<input type=hidden name="value2" value="<?php echo $value2;%>
<input type=hidden name="value3" value="<?php echo $value3;%>
<input type=submit value="Cancel">
</form>

Then on entrypage.php use:

<?php
$value1 = isset($_POST['value1']) ? $_POST['value1'] : "";
$value2 = isset($_POST['value2']) ? $_POST['value2'] : "";
$value3 = isset($_POST['value3']) ? $_POST['value3'] : "";
%>
....

<input type=text name="value1" value="<?php echo $value1;%>">
<input type=text name="value2" value="<?php echo $value2;%>">
<input type=text name="value3" value="<?php echo $value3;%>">

Of course, loops and arrays can make the coding simpler.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
  #4  
Old August 22nd, 2007, 04:55 AM
GarryJones
Guest
 
Posts: n/a
Default Re: php session failure

As you've found, history.back() is not foolproof. And what if they have javascript disabled?
Quote:
It's harder, but put the cancel button in a form. In that form have the values as hidden fields, i.e.
The strange thing is I have identical code that works for users
elsewhere on the site. In "user entry" the number of entries allowed
is 10 sets of 10. This is where users enter themselves and club
members into events.

This particular code is for the race organisers to enter the details
of particpiants who register "on the line" by filling in a form. The
race office then needs to be able to enter all this data. Some race
organisers need to key in several thousand entrants. I chose 30 at a
time as a balance between "ease of use" and "risk of lost data during
entry". (Not nice to have keyed in 3000 lines of code and see the
computer screen go blank when the tea lady trips over the cable just
as you where about to press enter).

Anyway, I have much more control about java being on and so on as it
is a limited number of people actually keying in this data. This entry
form is also hidden behind an admin login folder on the website and
this not open to the masses.

So its strange that history.back() works on the initial code but not
on this. My coding is identical except for the inclusion of more rows
and the fact that its behind a htaccess/htpasswd page.

However I have already stored the values as hidden on the preview page
so I simply need to use the "value=" on the form entry page to fix it.
So problem solved, but its still strange how identical code works/
doesn't work on the same website from my own pc.

Thanks for your help
Garry Jones
Sweden

  #5  
Old August 22nd, 2007, 05:05 AM
GarryJones
Guest
 
Posts: n/a
Default Re: php session failure

I solved it.

I simply removed the session_start() from the top of the user entry
form.

I dont use any session variables until the preview page when the
values are read in. Neither was I using the session_start() on the
other entry form I referred to above.

Ah, mayybe thats what ELINTPimp meant....? ie "do you have....?"
because its wrong to do so....???

Garry Jones
Sweden

  #6  
Old August 22nd, 2007, 11:45 AM
Jerry Stuckle
Guest
 
Posts: n/a
Default Re: php session failure

GarryJones wrote:
Quote:
Quote:
>As you've found, history.back() is not foolproof. And what if they have javascript disabled?
>It's harder, but put the cancel button in a form. In that form have the values as hidden fields, i.e.
>
The strange thing is I have identical code that works for users
elsewhere on the site. In "user entry" the number of entries allowed
is 10 sets of 10. This is where users enter themselves and club
members into events.
>
It can be a lot of things. For one thing, you're depending on the
browser cache to fill in the fields.
Quote:
This particular code is for the race organisers to enter the details
of particpiants who register "on the line" by filling in a form. The
race office then needs to be able to enter all this data. Some race
organisers need to key in several thousand entrants. I chose 30 at a
time as a balance between "ease of use" and "risk of lost data during
entry". (Not nice to have keyed in 3000 lines of code and see the
computer screen go blank when the tea lady trips over the cable just
as you where about to press enter).
>
A reasonable compromise.
Quote:
Anyway, I have much more control about java being on and so on as it
is a limited number of people actually keying in this data. This entry
form is also hidden behind an admin login folder on the website and
this not open to the masses.
>
You're not using java. You're using javascript. The only thing they
have in common are two 'a's, a 'j' and a 'v'.
Quote:
So its strange that history.back() works on the initial code but not
on this. My coding is identical except for the inclusion of more rows
and the fact that its behind a htaccess/htpasswd page.
>
And can also be dependent on the amount of data being entered.
Quote:
However I have already stored the values as hidden on the preview page
so I simply need to use the "value=" on the form entry page to fix it.
So problem solved, but its still strange how identical code works/
doesn't work on the same website from my own pc.
>
That's the only sure-fire way. Your way depends on certain behavior by
the browser (javascript enabled, cache enabled and large enough) which
can be changed by the user.

Quote:
Thanks for your help
Garry Jones
Sweden
>

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
  #7  
Old August 22nd, 2007, 11:45 AM
Jerry Stuckle
Guest
 
Posts: n/a
Default Re: php session failure

GarryJones wrote:
Quote:
I solved it.
>
I simply removed the session_start() from the top of the user entry
form.
>
I dont use any session variables until the preview page when the
values are read in. Neither was I using the session_start() on the
other entry form I referred to above.
>
Ah, mayybe thats what ELINTPimp meant....? ie "do you have....?"
because its wrong to do so....???
>
Garry Jones
Sweden
>
No, your first message was "session failure" - which is why he asked the
question. But your question has to do with javascript and history - and
has nothing to do with session failure.

See my other note - you're depending a lot on the browser which may or
may be configured to do what you want.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,989 network members.