Re: POST/GET problem

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

 



Sorry, there was an error...

  if (!empty($_POST['surname']))
      $surname=strtoupper( $_POST['surname'] );
  else
     echo "Empty name";


Luis Moreira wrote:

Try reading the variable before you use it :-)
For best protection, see first if something went through...

   if (!empty($_POST['surname']))
       $surname=strtoupper($surname);
   else
      echo "Empty name";

Luis


Martyn Kinder wrote:

Hi,

I am not sure if this is the correct group for this problem, so apologies if
I have got this totally wrong.
I have just installed PHP5 on a Windows XP machine with IIS (PWS).


phpinfo() seems OK.

However, when I try the following test script:

name.html looks like:

<html>
<body>
<center>
<FORM METHOD="POST" ACTION="name2.php">
<table>
       <tr>
               <th width="15%" nowrap><b>First Name</b></th>
               <td width="35%"><input type=text name = "name"></td>

               <th width="15%" nowrap><b>Last Name</b></th>
               <td width="35%"><input type=text name = "surname"></td>
       </tr>
</table>
<table>
  <INPUT TYPE="SUBMIT" VALUE="Submit" NAME="Submit">
  <INPUT TYPE="RESET" VALUE="Reset" NAME="Reset">
</table>
</Form>
</center>
</body>
</html>

and

name2.php looks like:
<html>
<body>
<?php

$surname=strtoupper($surname);

?>
<?php echo("<h3>Hello"),  $name, (" "), $surname, ("</h3>");?>
</body>
</html>

When I run the name.html script:

I get

Notice: Undefined variable: surname in c:\Inetpub\wwwroot\name2.php on line
5


Hello
Notice: Undefined variable: name in c:\Inetpub\wwwroot\name2.php on line 9


I think this works OK on PHP4 and Apache.

I have looked through the FAQ's etc. But I'm not sure if this is an idiot
fault or a configuration fault.


Is there a requirement to declare variables in PHP5 now?

Any suggestions please!

Thanks

Martyn




-- 
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Database Programming]     [PHP Install]     [Kernel Newbies]     [Yosemite Forum]     [PHP Books]

  Powered by Linux