Originally posted by kav
I just want to know why. Or maybe the setting involve or whatever.Hope someone can tell. This is how i always write.
page1.php
<a href=\"javascript:open_window('do.php?libraryid=$libraryid&edit=1')> hello</a>
<a href=\"javascript:open_window('do.php?libraryid=$libraryid&add=1')> hello</a>
do.php
if(isset($GET['edit']))
$hi=$GET['edit'];
if(isset($GET['add']))
$he=$GET['add'];
BUT MY FRIEND do it like this
$hi=$GET['edit'];
$he=$GET['add']; (without the isset())
if i do like he does without the isset, i will get an error msg saying
Notice : undefined index edit/add depends which i click at on page1.php
Anyone can tell me why?
I believe it's best to check if the variable is set first using 'isset' then assign the data to the variable using '$_GET'.
if you wanted you could use @ which turns off error handling.
e.g. if you did this:
$hi = @$GET['edit'];
$he = @$GET['add'];
this means that when no value is assigned to $hi and $he you won't get that nasty error message because of @ which effectively 'hides' error messages for that particular function, if you get my drift?
one more thing, looking at your code the reason you are getting errors because your using variables libraryid and edit instead of edit and add.