JackJack Posted May 14, 2006 Share Posted May 14, 2006 I want to create a form (sounds easy). When there is an error like [code]<?if($username){echo "Please type a username";}?>[/code]But i want this to appear on the top of the signup page not the next page.Please helpJJ Quote Link to comment Share on other sites More sharing options...
alpine Posted May 14, 2006 Share Posted May 14, 2006 target your form to itselfset the value of the form elements to contain the respective variableIt's many ways of doing this, here is one example[code]$show_form = 1;if(isset($_POST['submit'])){$show_form = 0;$name = $_POST['name'];if(empty($_POST['name'])){ print "Name is missing"; $show_form = 1;}else{ // prossess posted name}}if($show_form == 1){echo <<<__HTML_END<form action="this.php" method="post"><input type="text" name="name" value="$name" maxlenght="30" /><input type="submit" name="submit" value="Send Form" /></form>__HTML_END;}[/code] Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.