RE: how do I use same page for submit and results?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



or you can use check for the name of the submit button using a specific
SUPERGLOBAL array.

e.g.

if ( ! empty($_POST["submit"]) ) {
   /* form was submitted */
} else {
   /* form hasn't been submitted, show it */
   echo '<form name="something" method="post">'
	.'.... form fields/button goes here ....'
	.'<input type="submit" name="submit" value="send form">'
	.'</form>';
}


Best to check if a variable exists

Using the other method will throw an error: Notice: Undefined index: action
in c:\program files\apache group\apache\htdocs\testerr.php on line x...



Thanks,

Luke Woollard








-----Original Message-----
From: Joshua Stein [mailto:jcs@rt.fm]
Sent: Friday, 7 February 2003 5:29 AM
To: php-db@lists.php.net
Subject: Re:  how do I use same page for submit and results?


> But now I'm not using anything that I can check except for the
> button click. Any ideas how to do this?

assign a name to the button and check for that.

<input type="submit" name="action" value="Show List">

...

if ($_REQUEST["action"] == "Show List") {
   /* form was submitted */
   ...
} else {
   /* form hasn't been submitted, show it */
   ...
}


   -j.

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux