PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > comp.lang.php > no empty form fields after submitting form
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
no empty form fields after submitting form

Réponse
 
LinkBack Outils de la discussion
Vieux 14/09/2007, 17h23   #1
pepper.gabriela@gmail.com
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut no empty form fields after submitting form

Hello, a stupid question but...

page_A.php is a page with a form.
The user inserts text in four fields, then he clicks a submit button.
The data goes to page_B.php:
this page controls the data submitted, then echoes a message.
If there were problems with the submitted data the message says:
"a problem occurred with your data. Click here to come back to the
form" (page_A.php).
When the user comes back, he finds the fields white.

How can I do to show him what he submitted?

Thanks!

  Réponse avec citation
Vieux 14/09/2007, 17h39   #2
Michael Fesser
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: no empty form fields after submitting form

..oO(pepper.gabriela@gmail.com)

>page_A.php is a page with a form.
>The user inserts text in four fields, then he clicks a submit button.
>The data goes to page_B.php:
>this page controls the data submitted, then echoes a message.
>If there were problems with the submitted data the message says:
>"a problem occurred with your data. Click here to come back to the
>form" (page_A.php).
>When the user comes back, he finds the fields white.


You don't need two pages. Let page_A show and handle the form
processing. Submit the form to the same page, check the values and show
the form again if there's an error.

To keep the form data while moving from one page to another you would
have to store the values in a session.

Micha
  Réponse avec citation
Vieux 14/09/2007, 17h47   #3
pepper.gabriela@gmail.com
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: no empty form fields after submitting form

On Sep 14, 6:39 pm, Michael Fesser <neti...@gmx.de> wrote:
> To keep the form data while moving from one page to another you would
> have to store the values in a session.
>
> Micha




Ok, I'll use sessions, thanks!

  Réponse avec citation
Vieux 14/09/2007, 18h41   #4
Chuck Anderson
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: no empty form fields after submitting form

pepper.gabriela@gmail.com wrote:
> Hello, a stupid question but...
>
> page_A.php is a page with a form.
> The user inserts text in four fields, then he clicks a submit button.
> The data goes to page_B.php:
> this page controls the data submitted, then echoes a message.
> If there were problems with the submitted data the message says:
> "a problem occurred with your data. Click here to come back to the
> form" (page_A.php).
> When the user comes back, he finds the fields white.
>
> How can I do to show him what he submitted?
>
> Thanks!
>
>


Create a form on page B. Copy all of the $_POST variables into hidden
fields with a submit button that says, "Go Back."

--
*****************************
Chuck Anderson • Boulder, CO
http://www.CycleTourist.com
*****************************
  Réponse avec citation
Vieux 14/09/2007, 20h05   #5
RageARC
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: no empty form fields after submitting form

If you put them in the same page, it will be better for you. It will
ease the process.

[php]

if (isset($_POST['submit'])) {

# Process the form

if ($number_of_errors_in_the_form != 0) {

# Show the errors
# Display the Form Again.
# Example: print "<input type='text' name='fieldname' value='".
$_POST['fieldname']."' />";

} else {

# Tell the user everything went fine.

}

} else {

# Display the form.

}


  Réponse avec citation
Vieux 15/09/2007, 08h56   #6
pepper.gabriela@gmail.com
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: no empty form fields after submitting form


>
> Create a form on page B. Copy all of the $_POST variables into hidden
> fields with a submit button that says, "Go Back."
>




hi chuck, it sounds interesting (I imagine form on page B should point
page A), but what if the user clicks the back button of his browser?

  Réponse avec citation
Vieux 15/09/2007, 20h11   #7
Chuck Anderson
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: no empty form fields after submitting form

pepper.gabriela@gmail.com wrote:
>> Create a form on page B. Copy all of the $_POST variables into hidden
>> fields with a submit button that says, "Go Back."
>>
>>

>
>
>
> hi chuck, it sounds interesting (I imagine form on page B should point
> page A), but what if the user clicks the back button of his browser?
>
>


Yes, the form action on page B is to return to page A.

Clicking the Back button is fine. The browser loads the previous state
of page A, with the form fields still filled out.

I've even written a function that reads all of the elements in an array
(e.g., $_POST) and creates hidden form fields for each one. It can even
handle multi-dimensional arrays (e.g., $_POST variables that are
themselves, an array).

--
*****************************
Chuck Anderson • Boulder, CO
http://www.CycleTourist.com
The world is my country,
Science, my religion.
*****************************
  Réponse avec citation
Vieux 15/09/2007, 20h20   #8
Jerry Stuckle
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: no empty form fields after submitting form

Chuck Anderson wrote:
> pepper.gabriela@gmail.com wrote:
>>> Create a form on page B. Copy all of the $_POST variables into hidden
>>> fields with a submit button that says, "Go Back."
>>>
>>>

>>
>>
>>
>> hi chuck, it sounds interesting (I imagine form on page B should point
>> page A), but what if the user clicks the back button of his browser?
>>
>>

>
> Yes, the form action on page B is to return to page A.
>
> Clicking the Back button is fine. The browser loads the previous state
> of page A, with the form fields still filled out.
>


It will if you have the browser caching the page and haven't needed to
flush the cache. But you shouldn't depend on that behavior.

> I've even written a function that reads all of the elements in an array
> (e.g., $_POST) and creates hidden form fields for each one. It can even
> handle multi-dimensional arrays (e.g., $_POST variables that are
> themselves, an array).
>


That's the best way to handle things.

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


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 22h57.


Édité par : vBulletin® version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,12333 seconds with 16 queries