nadeem14375 Posted June 26, 2011 Share Posted June 26, 2011 Dear all, I have signup form, on clicking the submit button, the control goes to "process.php". where i check the form's required fields are filled or not, if not filled it come back to signup.php and show the message. "Please fill all the required fields". 1. Is this right way to do it? 2. I want to show the message bellow the submit button, but couldn't succeed. Regards: Quote Link to comment https://forums.phpfreaks.com/topic/240425-want-to-show-a-message-on-the-same-form-page/ Share on other sites More sharing options...
revraz Posted June 26, 2011 Share Posted June 26, 2011 Could just process the form on the same page, or set a session variable and when you return back to the signup page display the error. Quote Link to comment https://forums.phpfreaks.com/topic/240425-want-to-show-a-message-on-the-same-form-page/#findComment-1234910 Share on other sites More sharing options...
nadeem14375 Posted June 26, 2011 Author Share Posted June 26, 2011 Dear I want to check the condition on the same page "signup" not to go to the process page. At this time I do this as: 1. on signup page click on submit button. 2. the control goes to process_signup.php there a condition which check if the form is not filled, the control goes back to signup.php and show a message. "Please fill all the required fields". I am new to web development / php, so is this is right way to do check the form is filled or not? Regards: Quote Link to comment https://forums.phpfreaks.com/topic/240425-want-to-show-a-message-on-the-same-form-page/#findComment-1234927 Share on other sites More sharing options...
WebStyles Posted June 26, 2011 Share Posted June 26, 2011 Dear I want to check the condition on the same page "signup" not to go to the process page. At this time I do this as: 1. on signup page click on submit button. 2. the control goes to process_signup.php there a condition which check if the form is not filled, the control goes back to signup.php and show a message. "Please fill all the required fields". I am new to web development / php, so is this is right way to do check the form is filled or not? Regards: If you want to check it on the same page, you point your form to $_SERVER['PHP_SELF'] or manually put in the page's name (you can even leave it blank) and check if the form was submitted with something like: if(isset($_POST) && !empty($_POST)){ ... do form checking here, set error if necessary, or redirect to some other page }else{ just show form and error if it was set. } alternatively, you can just include the form-checking script if $_POST is not empty. hope this helps Quote Link to comment https://forums.phpfreaks.com/topic/240425-want-to-show-a-message-on-the-same-form-page/#findComment-1234998 Share on other sites More sharing options...
ZulfadlyAshBurn Posted June 27, 2011 Share Posted June 27, 2011 You may want to use ajax for you site? I used ajax for my site to check for the data Quote Link to comment https://forums.phpfreaks.com/topic/240425-want-to-show-a-message-on-the-same-form-page/#findComment-1235267 Share on other sites More sharing options...
TeNDoLLA Posted June 27, 2011 Share Posted June 27, 2011 You want to use also $_SERVER['SCRIPT_NAME'] instead of $_SERVER['PHP_SELF'], since PHP_SELF has XSS security holes used just plain like that. Quote Link to comment https://forums.phpfreaks.com/topic/240425-want-to-show-a-message-on-the-same-form-page/#findComment-1235317 Share on other sites More sharing options...
EdwinPaul Posted June 27, 2011 Share Posted June 27, 2011 You want to use also $_SERVER['SCRIPT_NAME'] instead of $_SERVER['PHP_SELF'], since PHP_SELF has XSS security holes used just plain like that. and even better: <form action="" method="post"> <!-- no action indicates: same script --> Quote Link to comment https://forums.phpfreaks.com/topic/240425-want-to-show-a-message-on-the-same-form-page/#findComment-1235323 Share on other sites More sharing options...
TeNDoLLA Posted June 27, 2011 Share Posted June 27, 2011 You want to use also $_SERVER['SCRIPT_NAME'] instead of $_SERVER['PHP_SELF'], since PHP_SELF has XSS security holes used just plain like that. and even better: <form action="" method="post"> <!-- no action indicates: same script --> Yeah thats true for all the mainstream browsers, but might not work on all browsers like some cuztomized browsers on some mobile platforms. Quote Link to comment https://forums.phpfreaks.com/topic/240425-want-to-show-a-message-on-the-same-form-page/#findComment-1235343 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.