Re: good practice
| From: | Steven Walker | Date: | Thu, 14 Feb 2002 19:20:46 +0000 |
| Subject: | Re: good practice | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-84797@lists.php.net to get a copy of this message | ||
I don't understand what you are trying to do...
If you need to verify whether the page has already been submitted to itself, you can test any of the form variables using isset(). For example:
<?
if(isset($name)) {
$LoadedBefore = 1;
}
if(!$LoadedBefore) {
echo "<form name='form1' action='$PHP_SELF'>";
echo "<input type='text' name='name'>";
echo "<input type='submit' name='submitdata' value='submit'>";
}
?>
You can also pass the data back into the form:
echo "<input type='text' name='$name'>"; // using $name variable as value
Steven J. Walker
Walker Effects
www.walkereffects.com
steve@walkereffects.com
On Thursday, February 14, 2002, at 11:09 AM, James Taylor wrote:
Can someone recommend a better method for doing something like the following?
All of my programs are written like this, but it's really poor form
considering I'm not predeclaring my variables, etc. Only thing I can really
think of is to assign a value in the form a number like 1 or something, then
do a if $value == 1 {do something} but that seems kinda hokey. Here's an
example of something I'd do:
<HTML><BODY>
<?
if ($submitdata) {
dosomething;
exit;
}
echo "<form name=\"form\" action=\"$PHP_SELF?\">\n";
echo " <input type=\"text\" name=\"data\">\n";
echo " <input type=\"submit\" name=\"submitdata\" value=\" Submit \">\n";
echo "</form>\n</body>\n</html>";
?>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php