If I understand your problem/issue here, you are talking about something
called 'sticky forms'.
This means -
(i) the form references itself.
(ii) that the form knows what the previous data was when it encounters any
validation issues.

You achieve (i) and (ii) by re-submitting the form with the usage of a
superglobal variable called $_SERVER['PHP_SELF'].

<form method='POST' action ="<php echo $_SERVER['PHP_SELF'] ?>" >


On Sun, Jul 4, 2010 at 11:27 PM, David Mehler <dave.meh...@gmail.com> wrote:

> Hello,
> I've got a form with several required fields of different types. I
> want to have the php script process it only when all the required
> fields are present, and to redisplay the form with filled in values on
> failure so the user won't have to fill out the whole thing again.
> One of my required fields is a text input field called name. If it's
> not filled out the form displayed will show this:
> <input type="text" name="name" id="name" size="50" value="<?php
> echo($name); ?>" /> <br />
> Note, I've got $_POST* variable processing before this so am assigning
> that processing to short variables.
> If that field is filled out, but another required one is not that form
> field will fill in the value entered for the name field.
> This is working for my text input fields, but not for either select
> boxes or textareas. Here's the textarea also a required field:
> <textarea name="description" id="description" cols="50" rows="10"
> value="<?php echo($description); ?>"></textarea>
> What this does, if a user fills out this field, but misses another, it
> should echo the value of what was originally submitted. It is not
> doing this. Same for my select boxes, here's one:
> <select name="type" id="type" value="<?php echo($type); ?>">
> <option value="0" selected="selected">-- select type --</option>
> <option value="meeting"> - Meeting - </option>
> <option value="event"> - Event - </option>
> </select>
> I'd also like for any not entered required fields to have an error box
> around them, I've got a css class to handle this, but am not sure how
> to tie it in to the fields since any one of the required fields could
> not be filled in.
> I'd appreciate any help.
> Thanks.
> Dave.
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php

Shreyas Agasthya

Reply via email to