You are here: Re: php session failure « PHP Programming Language « IT news, forums, messages
Re: php session failure

Posted by Jerry Stuckle on 08/21/07 22:51

GarryJones wrote:
> 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
==================

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация