On Tue, Nov 24, 2009 at 06:14:01PM +0100, Merlin Morgenstern wrote:

> Hi there,
> I am trying to redirect a user back to a html form if a validation
> failes. The form shoult then hold all entered values. So far I did this
> over $_GET, but there is a 100 Character limitation. How could I do this
> while keeping all characters?
> Thank you for any hint,

*Don't* use GET for this.

Here's the typical way this is done:

If the name of the file is myfile.php, then in the file do this:

<form action="myfile.php" action="post">

This makes the form return to itself when the user hits the "Submit"
button. Above the actual HTML part of the form, put a check to determine
if the form has been filled in, like this:

if (!empty($_POST)) {
        // Form was filled in
        if (! $valid) {
                $_SESSION['myform'] = $_POST;
else {

In the do_validation() step, you validate the form. If there is a
problem and you want to re-show the form, you would typically do this
for each field:

<input type="text" name="first_field" value="<?php echo
$_SESSION['myform']['first_field']; ?>" ?>

In other words, you store the form values in the $_SESSION array.


Paul M. Foster

PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to