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 Link to comment https://forums.phpfreaks.com/topic/9642-form-troubles/ 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] Link to comment https://forums.phpfreaks.com/topic/9642-form-troubles/#findComment-35656 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.