Page 1 of 1

problem with $_GET or $_POST in xampp for windows

PostPosted: 12. May 2011 16:06
by matijaz74
Hi!
I have a problem.
Simple code:

Code: Select all
<?php
 if($_GET["p"]!=""){
 }
?>


I have install xampp version 1.7.4. What is wrong or why?
Thanks for help me.

Matijaž

Re: problem with $_GET or $_POST in xampp for windows

PostPosted: 12. May 2011 16:38
by Altrea
Maybe it is easier to help you if you tell us, what exactly your problem is.

Re: problem with $_GET or $_POST in xampp for windows

PostPosted: 12. May 2011 17:07
by matijaz74
Altrea wrote:Maybe it is easier to help you if you tell us, what exactly your problem is.


Uppss ... sorry :)

This is problem:
Code: Select all
Notice: Undefined index: p in C:\xampp\htdocs\vsiza.si\testi\durs\index.php on line 10

Re: problem with $_GET or $_POST in xampp for windows

PostPosted: 12. May 2011 23:47
by Altrea
Well, "p" isn't set in your $_GET Array at this point which is a little bit sloppy programming style if you don't check that.
use the php functions isset() or empty() to check if a variable or Array key is set or empty

change
Code: Select all
if($_GET["p"]!=""){


to
Code: Select all
if(isset($_GET["p"]) && $_GET["p"] !=""){


and your Notice is gone.