Re: If + Multiple forms help
| From: | Richard Lynch | Date: | Sat, 20 Jul 2002 06:56:24 +0000 |
| Subject: | Re: If + Multiple forms help | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-108638@lists.php.net to get a copy of this message | ||
>Im currently having a problem when I have multiple forms on the same page (I
>assume that this is the problem).
You're not showing us how $include and $submit are getting set, so we really
can't help you much...
>im currently doing something like this:
For starters, indent your code like this:
<?
if(!$include) {
if(!$submit) {
?>
//html
<?
}
if($submit) {
//do some code
}
}
if(($include) && ($include == "send")) {
if(!$submit_send) {
?>
//html goes here
<?
}
if($submit_send) {
//code goes here
}
}
?>
Also, if you have:
if ($foo){
}
if (!$foo){
}
it should probable be:
if ($foo){
}
else{
}
Unless, you are changing the value of $foo in the first block (inside the
if)
>Okay now this is what happens, the first form works fine even if there is an
>include. The second one ($submit_send) does not, it just reloads the page
>without actually doing any code.. it seems to stop right before the
>if($submit_send). I was wondering if it could be because I had multiple
>forms in the script (but im only accessing one at the time).
My best guess is that you are assuming $include will be "set" the second
time you come back.
It won't.
Unless you pass its variable on from FORM to FORM using:
<INPUT TYPE=HIDDEN NAME=include VALUE="<?=htmlentities($include);?>>
or you use sessions (http://php.net/session_start) to register it.
HTTP is "stateless"
That means that every time you click a link or hit a button on a FORM, the
next page knows *NOTHING* about the previous page.
Or, rather, it only knows the things you explicitly "pass on" in your
FORM/URL or in sessions. No knowledge is "kept" from page to page.
>Im really stuck at the moment, to me, it should work, but its not. I don't
>get any errors, it just seems to skip right over the code section for
>$submit_send .
--
Like Music? http://l-i-e.com/artists.htm