I'm having a problem? Don't know what the problem is?
The code is as follows:
[Email Protected]_connect ("localhost", "root", "1234567")//database server needs to be connected before selecting a database
Or Die ("Database server Connection Failed");
[Email protected]_select_db ("Test"//Select Database MyDB
Or Die ("database does not exist or is not available");
Execute SQL statement
$query = @mysql_query ("Select Username, userflag from users"
//." where username = ' $username ' and passcode = ' $passcode ' ")
Or Die ("SQL statement execution failed");
Determine if the user exists, the password is correct
if ($username = = "HHH" && $passcode = = "12345")
{
Switch ($cookie)//Set cookie save time according to user's choice
{
Case 0://Save cookie for browser process
Setcookie ("username", $username);
break;
Case 1://Save 1 days
Setcookie ("username", $username, Time () +24*60*60);
break;
Case 2://Save 30 days
Setcookie ("username", $username, Time () +30*24*60*60);
break;
Case 3://Save 365 Days
Setcookie ("username", $username, Time () +365*24*60*60);
break;
}
Header ("location:main.php"); Auto Jump to main.php
}
else{
echo "User name or password error";
}
?>
The problem tip is this: notic:undefined Inder:passcode in C:\wamp\www\ti\index.php on line 8
notic:undefined Inder:passcode in C:\wamp\www\ti\index.php on line 9
notic:undefined Inder:passcode in C:\wamp\www\ti\index.php on line 10
But very strange, my classmates and I are exactly the same, they can run, I can not, I copy their, on my computer also not, in the computer room also not!
The mobile browser should look like configuration.
------Solution--------------------
This is the new version of PHP features that have time to look at the underlying issue of the pinned article.
Precede the variable with if (Isset ($passcode)) {and then proceed with the action so that no prompt is present
------Solution--------------------
Of course you can also set the php.ini error display level will be prompted to close, but I do not recommend this
------Solution--------------------
$passcode = $_post [' passcode ']; Does not have this field name, and must be judged before using $passcode, whether it is empty or null (), or if there is a isset ()
------Solution--------------------
$username = $_post [' username '];
$passcode = $_post [' passcode '];
$cookie = $_post [' Cookie '];
This only works when the form is submitted as post
When running alone, an error occurs because it does not exist
You can go without it, or you can use
if ($_server[' request_method '] = = "POST") {
Your code
}
Wrap it up.
------Solution--------------------
PHP.ini Configuration
error_reporting = E_all & ~e_notice
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.