RE: isset not functioning

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Io, try do like this:

 

You should use $_POST for the security, using $_REQUEST some users can pass a inject or someting to crash the aplication, and addslashes is for more security

 

$firstName = addslashes($_POST['firstname']);

 

if(isset($firstName) && !empty($firstName)) {
    $name = $firstName;
} else {
    $name = 'Sir or Madam';
}


Yuri Yarlei.
Programmer PHP, CSS, Java, PostregreSQL;
Today PHP, tomorrow Java, after the world.
Kyou wa PHP, ashita wa Java, sono ato sekai desu.


 
> Date: Mon, 3 Aug 2009 10:08:08 -0700
> From: allenmccabe@xxxxxxxxx
> To: parham90@xxxxxxxxx
> CC: php-general@xxxxxxxxxxxxx
> Subject:  isset not functioning
> 
> I created a simple survey for my work website, most of the PHP is on my
> process.php document, which is referenced by a form on a seperate page
> containing the form with the method of "post".
> 
> On my process.php page, the script obtains the field data using the
> $_REQUEST[] function.
> 
> I have a small if statement to check to see if they filled out the
> 'firstname' field, and if they did not, to replace $name with "Sir or
> Madam". Unfortunately, $name always equals "Sir or Madam", wether a value
> for "firstname" was entered or not.
> 
> All the of the other instances of using $_REQUEST[] functions just fine, but
> don't make use of if or isset. Here is the code snippet:
> 
> if(isset($_REQUEST['firstname']) && !empty($RESULT['firstname'])) {
> $name = $_REQUEST['firstname'];
> } else {
> $name = 'Sir or Madam';
> }
> 
> I also tried adding an underscore to $RESULT (I got the code for this from a
> php.net comment on the manual), to make it $_RESULT, but this doesn't seem
> to be a pre-set function, and it still does not make it work. I am guessing
> the user neglected to define $RESULT in his snippet, or I overlooked it.
> 
> Can anyone see any problems with the code?

_________________________________________________________________
Novo Internet Explorer 8. Baixe agora, é grátis!
http://brasil.microsoft.com.br/IE8/mergulhe/?utm_source=MSN%3BHotmail&utm_medium=Tagline&utm_campaign=IE8

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux