Click here to get back home

FF triggering $_POST array even on no submission?

 HomeNewsGroups | Search

comp.lang.php - PHP programming language discussions 

get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
FF triggering $_POST array even on no submission? lawpoop 03-03-2009
Posted by lawpoop on March 3, 2009, 2:14 pm
Please log in for more thread options
I'm writing a page where I have a javascript function that validates
some form fields before a submission. I'm troubleshooting it, and I
think it's prematurely submitting the form.

I wrote a test at the beginning of my page to test whether $_POST is
an array, and in FireFox 3.0.6 it's always an array, even before any
submission. I've tried IE 6.8.2, and $_POST does not start out as an
array.

What's going on here? It looks to me like a problem with FireFox -- it
must be sending something to the server to indicate that there are
some POST values, even if there are none. I say it's in FF, because if
it were a problem with the web server, then IE should be triggering
POST also.

I can make a more robust $_POST test by using count() or checking for
certain values, but I am just wondering what's going on here.

Posted by lawpoop on March 3, 2009, 4:42 pm
Please log in for more thread options
Here's another way of asking my question -- does the $_POST array
always exist, no matter how the page was requested? So if the page
wasn't generated from a POST request, the variable $_POST should
regardless be an array with no values?

Posted by Tim Roberts on March 6, 2009, 2:07 am
Please log in for more thread options
show/hide quoted text

This paragraph is well intentioned, but it has so much confusion that it
makes things worse. The browser does NOT generate the $_POST array, and
that array never lives on the client. The browser uses the form data to
generate and send an HTTP POST request, then PHP (on the server) generates
the $_POST array from that request.

Further, the server does not "send PHP". The server can cause a PHP script
to be executed, but that PHP script will generate HTML, and it is only the
HTML that goes back to the browser.
--
Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.

Posted by Scott Johnson on March 6, 2009, 9:05 am
Please log in for more thread options
Tim Roberts wrote:
show/hide quoted text

Wow I am glad you caught that. It is amazing how many amateurs (with
good intentions), send out bad information and do not understand PHP and
its abilities.

Scotty

Similar ThreadsPosted
Triggering PHP script from Windows XP machine February 4, 2008, 2:42 pm
$post array has nothing in it May 9, 2009, 5:51 am
Triggering a mysql query on page load July 28, 2004, 3:40 pm
Variable passed in GET or POST array January 18, 2006, 11:17 pm
Re: Trying to change global array value with $POST September 7, 2009, 6:02 pm
Post array values (beginner's question) September 27, 2005, 5:22 pm
Form value submission problems March 8, 2006, 9:03 pm
Alternative form submission February 10, 2007, 10:58 am
a tricky one (or not) about form submission February 14, 2008, 10:05 am
Capturing results of a Form Submission November 12, 2004, 3:27 am

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Driving a better car - Fuelzilla.com

Cabling site for homeowners and pros alike - Cabling-Design.com

Friends:

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap
Privacy Policy