Re: detecting POST variables

From: Date: Tue, 08 Oct 2002 00:16:33 +0000
Subject: Re: detecting POST variables
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-119170@lists.php.net to get a copy of this message
on 08/10/02 9:13 AM, Anup (anup_patel@rogers.com) wrote: > Hello, I have been dealing with different form proccessing PHP scripts. When > I start a new job I usually have a script that just takes the form POST > values and prints them to the screen, so I know what I'm working with. Now > I have a question say the form has 1 field named "FirstName". If the field > is left blank, sometimes my script will print the key and NO value, or it > will just print out nothing, ie NO key or value. Are you certain this is happening on text fields? Typically text fields, password fields and textareas allways set a key, and no value of blank. Ie: $_POST['FirstName'] = ''; Select boxes should always have a value set. Check boxes are only set IF the box was ticked. What I'd advise is that you make a quick form and test this out -- perhaps it was only checkboxes that were sometimes not being set? > any ideas. Could it be the server (IIS or Unix/Linux) of the form and the > server (IIS or Unix/Linux) of the script.? > Since I do jobs for different people and environments any combination of > servers are possible. I've never experienced this problem on any environment -- FreeBSD, RedHat or Windows. > The reason, for this post is that I don't know if I should always put code > to check for validilty using isset all the time or should I put it in just > in case the script gets moved. I want to pinpoint this so that I can write > more effective code. You should be able to use isset() or empty() on text/password/textarea form elements reliably. Write a SMALL test script, test it, and if it ain't working, post the code :) Justin

« previous php.general (#119170) next »