Makeshift67 Posted March 18, 2009 Share Posted March 18, 2009 hey guys. i recently put a PHP comment submit form on my site, and it works fine. the only problem is when it goes to the page that saves and posts the provided information, if they just type in the URL, it will post a blank form. also, i am also looking to make the form error if not all fields are filled out. thanks for any help. Quote Link to comment https://forums.phpfreaks.com/topic/149910-comment-submit-form/ Share on other sites More sharing options...
Floydian Posted March 18, 2009 Share Posted March 18, 2009 Okay, so it posts a blank form. Are we to assume you want to prevent that... As for making the form to error if all fields aren't filled out, use some if blocks for that. if (!isset($_POST['FOO']) or strlen($_POST['FOO']) < 1) { echo "<h2>Please fill in all fields.</h2>"; die(); } Quote Link to comment https://forums.phpfreaks.com/topic/149910-comment-submit-form/#findComment-787305 Share on other sites More sharing options...
Makeshift67 Posted March 18, 2009 Author Share Posted March 18, 2009 okay, that helped a lot. thanks. Quote Link to comment https://forums.phpfreaks.com/topic/149910-comment-submit-form/#findComment-787316 Share on other sites More sharing options...
rameshfaj Posted March 18, 2009 Share Posted March 18, 2009 You can also use client side validations using javascript for such small stuffs rather than returning back the way through the server. Quote Link to comment https://forums.phpfreaks.com/topic/149910-comment-submit-form/#findComment-787476 Share on other sites More sharing options...
redarrow Posted March 18, 2009 Share Posted March 18, 2009 here a nice way to validate code. <?php $array=array("name"=>"redarrow","password"=>"1234","email"=>"[email protected]"); if(strlen($array['name'])>3){ $war[]="Sorry name to long!"; } if(strlen($array['password']>1)){ $war[]="Sorry password to small"; } if(strlen($array['email'])>1){ $war[]="Sorry email to big"; } foreach($war as $result){ echo "$result<br>"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/149910-comment-submit-form/#findComment-787495 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.