Web Design Forum: Form Submission - Web Design Forum

Jump to content

WDF
WDF Premium Memberships Reseller Hosting
Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Form Submission Rate Topic: -----

#1 User is offline   gadgetgirl 

  • Dedicated Member
  • PipPip
  • Group: Members
  • Posts: 152
  • Joined: 26-February 10
  • Reputation: 6

Posted 10 January 2012 - 09:59 AM

In most of my forms I include a hidden field set to true. Then in my php validation I check
 if(isset($_POST['submitted'])) 
. Recently I have come across this method
if($_SERVER['REQUEST_METHOD'] == 'POST')

Do they both do the same thing? Is one method better than the other to use and why?
0

#2 User is offline   GalaxyTramp 

  • Dedicated Member
  • PipPip
  • Group: Members
  • Posts: 120
  • Joined: 09-December 11
  • Reputation: 16
  • Gender:Male
  • Experience:Intermediate
  • Area of Expertise:Web Developer

Posted 10 January 2012 - 12:12 PM

View Postgadgetgirl, on 10 January 2012 - 09:59 AM, said:

In most of my forms I include a hidden field set to true. Then in my php validation I check
 if(isset($_POST['submitted'])) 
. Recently I have come across this method
if($_SERVER['REQUEST_METHOD'] == 'POST')

Do they both do the same thing? Is one method better than the other to use and why?


if($_SERVER['POST'] == 'POST')

If the request method equal "POST" then the contents will be processed regardless of the content, you are not checking for a specific value.

if(isset($_POST['submitted']))

With this you are checking for a specific value "submitted"

So no they are not the same and only the second example really does any validation, the first just checks if the request method equals POST in this instance.

Hope this helps

Colin
0

#3 User is offline   webdesigner93 

  • Web Guru
  • PipPipPipPipPip
  • Group: Members
  • Posts: 1,976
  • Joined: 22-September 09
  • Reputation: 222
  • Gender:Male
  • Experience:Web Guru
  • Area of Expertise:Web Developer

Posted 10 January 2012 - 04:36 PM

View Postgadgetgirl, on 10 January 2012 - 09:59 AM, said:

In most of my forms I include a hidden field set to true. Then in my php validation I check
 if(isset($_POST['submitted'])) 
. Recently I have come across this method
if($_SERVER['REQUEST_METHOD'] == 'POST')

Do they both do the same thing? Is one method better than the other to use and why?

I'd personally use
 if(isset($_POST['submitted'])) 
this is specifically checking if the submit button is pressed, and if it is then you run your processing code or you can do both i guess. checking the request method and also checking if the submit button is clicked
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users