Jump to content

want to show a message on the same (form) page.


nadeem14375

Recommended Posts

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:

 

Link to comment
Share on other sites

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:

 

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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    -->

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.