You are here: Re: Re-draw a form with user's input. « PHP Programming Language « IT news, forums, messages
Re: Re-draw a form with user's input.

Posted by Kimmo Laine on 10/17/58 11:20

"Jay" <goofyfish@gmail.com> kirjoitti
viestissδ:1120344469.430289.220610@g14g2000cwa.googlegroups.com...
> Hi everybody!
>
> Please help me with this problem. I try to write code for server side
> data validation. Initially, I have a html file called "form.html" which
> just contains all the necessary fields for user to submit their contact
> info (name, phone, email, address.....etc...). All user's input will be
> sent to "processForm.php" using POST. In processForm.php, I want to be
> able to re-display the form in "form.html" with valid user's input and
> error message on top of the form in case user enter invalid data.
> Currently, a simple code that I could think of is the following:
>
> <?php
>
> if (!empty($_POST['submit']))
> {
> $isAllValid = false;
>
>
> //Check for invalid data
> //Code for checking data will be written here.
>
> //Invalid data occur.
> if(!$isAllValid)
> {
> include("form.html");
>
> //set user's input in the form's fields. How to access
> //form's field form here ?
> }
> }
> else
> {
> echo "User not submit";
> }
>
> ?>
>
>
> My questions are:
>
> 1. Is there a way to access the form's fields in "form.html" to set
> their values ? (given all the form's fields in form.html have unique
> name)
>
> 2. If (1) is not doable, then how would I this in PHP ?


Simply set the value attribute of each field.

<input type="text" name="foo" value="<?= $_GET['foo'] ?>">

I'd say it works even though the file is called form.html, since you are
including the page, not passing it thru. In that case php tags should be
executed...

--
"I am pro death penalty. That way people learn
their lesson for the next time." -- Britney Spears

eternal.erectionN0@5P4Mgmail.com

 

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

Π‘Π°ΠΉΡ‚ ΠΈΠ·Π³ΠΎΡ‚ΠΎΠ²Π»Π΅Π½ Π² Π‘Ρ‚ΡƒΠ΄ΠΈΠΈ Π’Π°Π»Π΅Π½Ρ‚ΠΈΠ½Π° ΠŸΠ΅Ρ‚Ρ€ΡƒΡ‡Π΅ΠΊΠ°
ΠΈΠ·Π³ΠΎΡ‚ΠΎΠ²Π»Π΅Π½ΠΈΠ΅ ΠΈ ΠΏΠΎΠ΄Π΄Π΅Ρ€ΠΆΠΊΠ° Π²Π΅Π±-сайтов, Ρ€Π°Π·Ρ€Π°Π±ΠΎΡ‚ΠΊΠ° ΠΏΡ€ΠΎΠ³Ρ€Π°ΠΌΠΌΠ½ΠΎΠ³ΠΎ обСспСчСния, поисковая оптимизация