Re: form values
| From: | Pavel Kalian | Date: | Mon, 02 Oct 2000 08:54:15 +0000 |
| Subject: | Re: form values | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-18258@lists.php.net to get a copy of this message | ||
----- Original Message -----
From: "bryan brown" <donmon_98@yahoo.com>
To: "php" <php-general@lists.php.net>
Sent: Monday, October 02, 2000 10:28 AM
Subject: [PHP] form values
> Ill continue posting this question in hopes to get
> a solution that works. I have a php page with a bunch
> of forms. The user inputs the values and the values
> are checked for validity in another php file like
> this:
>
> if (! (ereg("^[a-zA-Z ]+$", $f_name))){
> $errorflag1 = 1;
> $a = 1;
> include('userform.php3');
> }
>
> If there is an error, it goes back to that page.
> Otherwise, it goes to the next php page with more
> forms, which are also checked for correct values.
> I lose the values from the first form page and thus
> cannot insert into a db (because they cant be null).
> Most people suggested that hidden variables would
> remedy this. I have code like so, in the second form:
>
> <input type=hidden name='fname'<?php "
> value='$f_name'>"; ?>
1) it should be at least <input type=hidden name='fname'<?php echo "
value='$f_name'>"; ?>
but <input type=hidden name='fname' value='<?php echo "$f_name";
?>'> looks
much nicer to me.
Also naming the variable $f_name on the first page and $fname on the second
doesn't improve understandability of your code in the future, IMHO
2) Don't forget that you have to submit the form even if it contains just
hidden fields to pass them to the next page. If you just redirect to the
next form after your check the form values are lost and you have to pass the
values as part of URL - header("Location: TARGET?fname=$fname");
HTH
Pavel
Pavel