note 29517 modified in tutorial.forms by betz

From: Date: Mon, 24 Feb 2003 23:14:00 +0000
Subject: note 29517 modified in tutorial.forms by betz
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-44464@lists.php.net to get a copy of this message
[editors note]: This will only work with register_globals on and for security reasons not recommended. Use $_POST['name'] instead. To add the both into 1 page correctly you need to add an if else test. <?php if(!$Name) { // Switch to HTML mode to display form ?> <form action="action.php" method="post"> Name: <input type="text" name="Name" size="24"> <input type="submit" value="Submit"> <?php }else{ ?> Hello <?php echo($Name); ?> ! <?php } ?> notice how the if and else work? the cool part about this is that for each if test you can have it output different things if they left different fields blank :-) --was-- To add the both into 1 page correctly you need to add an if else test. <?php if(!$Name) { // Switch to HTML mode to display form ?> <form action="action.php" method="post"> Name: <input type="text" name="Name" size="24"> <input type="submit" value="Submit"> <?php }else{ ?> Hello <?php echo($frmName); ?> ! <?php } ?> notice how the if and else work? the cool part about this is that for each if test you can have it output different things if they left different fields blank :-) http://www.php.net/manual/en/tutorial.forms.php

« previous php.notes (#44464) next »