warning while using $_get

Hi,
Respected members, i am a beginner in PHP…
I am making a registration which works fine but on the page i got this error because i use $_Get

Notice: Undefined index: e in D:\xampp\htdocs\login\login.php on line 20

actually the logic i used is, login page checks if the cookie is empty it goes to the check page which checks if the user put the wrong password & cookie is also empty then a variable send a value by get method & the login page get the value by id & it shows an error…

ALL is work fine but when i open the login page first time…i mean, before submitting form it show me an above warning…This also happen when i used $_Post method.

Remeber i am using these logic to familiarize with PHP functions, as i mentioned above,i know there will be also many other ways, but i just want to familiarize my self with all the techniques of PHP.

Kindly help me to sort out this problem.

Hi there,

So we can better help you with your problem, please post your code so we may pinpoint the problem.

Thanks.

Thank you respected friend,
& i solve the warning visibility issue by hiding the warnings…

but until now i dont under stand why $_GET make a problem…
following is the code file for login

<?php ini_set('display_errors', 0);

if(!empty($_COOKIE[‘user’])&& !empty($_COOKIE[‘pwd’])){
header(“Location:checkuser.php”);
}
?>

<title>Login Page</title>
<link href="style.css" rel="stylesheet" type="text/css" />
<?php

[size=10pt]$verify = $_GET[‘e’]; //this line shows an error[/size]
if($verify==2){
print "<table align=“center” class=“login-error”>

";
print “Sorry! we cant match user id & password, Kindly try again!”;
print “”;

}
?>

Login...

Welcome To The Login Page
user id:
password:
Remeber me

Hi there,

I’m not sure if you are aware of this, but $_GET variables are collected from the URL (so to speak).

www.mysite.com?first=this&second=that

At the url above, $_GET[‘first’] contains “this” and $_GET[‘second’] contains “that”
If “&second=that” wasn’t in the URL, $_GET[‘second’] is not set (hence the error you are getting)

If the URL does indeed contain &e=something, let us know.

yes respected friend i know this,
but i want to know, is there any way to solve this?
or any other alternate logic have to used…?

u can see in the code i use $_GET to verify the user…i do hide the warning by

ini_set(‘display_errors’, 0);
is it the the right way to do this?

Thanks for your reply firend:)

You appear to be using numbers for your logic in the $verify variable.

You could try replacing that line that errors with this:
[php]$verify = (isset($_GET[‘e’]) && !empty($_GET[‘e’])) ? $_GET[‘e’] : 2; //If $_GET[‘e’] is set and not blank, take it’s value - if not, set $verify to 2[/php]

Thankyou very much respected smooky for teach me:)

it work fine i use
$_GET[‘e’] : 1
so the default value is 1,now the normal page isn’t showing an error but if the user place wrong id & password value of get the value 2 then it will shows an error…!

Once again thankyou very much

Good to hear - not a problem. Glad to have helped :smiley:

thank you,
so can i ask another question? :wink:

Sure, go ahead - hopefully I’ll be able to help with that one as well

Sponsor our Newsletter | Privacy Policy | Terms of Service