Registration form - Checking if data entered ($_SERVER['PHP_SELFf'])

What I want to do is,

  1. User comes to registration form.
  2. Fills it , press enter, registration goes on.
  3. If he doesnt fill it, echo Data Missing.

Where I am stuck,

  1. Using isset, it echos Data Missing at the first visit itself which shouldnt happen.

Any suggestions?

I am not looking for any codes as I want to learn it up myself. Just the idea would do.


On the first form load, check the contents of $_SERVER['REQUEST_METHOD']

  // Verify the form has been filled in 
  // If any are missing, display missing data message
  // and display the form again
else {
  // Just display the form for the first time

I also recommend reading up on the post-redirect-get pattern, wherein you display the form from a script which does no form processing itself. The form posts to another handler script (rather than back to itself), which does all the validation and action, and finally redirects to a new location or back to the original form on error or incomplete data.

Read more about the $_SERVER superglobal array.

Can you put the "action" code in another page?

That's what I normally due, mostly to prevent the user from resubmitting the data on a page refresh, but it would also resolve your issue.

Alternatively, you could take into consideration PHP upload - Why isset($_POST['submit']) is always FALSE in which they make some valid points about the isset function.

Need Your Help

onListItemClick listener doesn't work

android android-listview android-fragmentactivity onitemclicklistener

In my fragment i have a listview and when i click would open another activity that correspond at the item in the list.. But actually doesn't work and when i click nothing happen.

Inserting Variable into DIV within a Javascript Function

php javascript jquery wordpress simplemodal

Just to put it out there if I say the wrong lingo, I have literally less than 4 hours experience in Javascript for starters. What I am trying to do is add a variable to the end of a predefined DIV...