Re: Checking for form submission

From: Date: Wed, 04 Aug 2004 09:34:47 +0000
Subject: Re: Checking for form submission
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-192681@lists.php.net to get a copy of this message
Hi Shaun, Your expression is evaluating, if you like does the $_POST superglobal exist and it does but might be empty, this would be the same for $_GET and other superglobals. If you did the following: if (isset($_POST) && !empty($_POST)) { echo '(isset($_POST))'; } This would only appear if there was in fact a $_POST variable 'set'. If you want to test to see if a form has been submitted, I would suggest that you use the name from the submit button. e.g - <input type="submit" value="Send Form Data" name="sendform"> if(isset($_POST['sendform'])){ echo "Form has been submitted!"; } So basically this checks if the form button "sendform" is set. HTH, Craig "Shaun" <shaun@mania.plus.com> wrote in message news:20040804092520.27664.qmail@pb1.pair.com... > Hi, > > I am trying to create some code to check whether a form has been submitted. > The following code seems to print evertime, whether a form has been > submitted or not: > > if (isset($_POST)) { > echo '(isset($_POST))'; > } > > This seems most odd, could someone tell me why this happens? > > Thanks for your help.

« previous php.general (#192681) next »