Little brother my appearance related issues? I don't know anything about it.

Source: Internet
Author: User
Tags set cookie
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");

Get user input
$username = $_post [' username '];
$passcode = $_post [' passcode '];
$cookie = $_post [' Cookie '];

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!

------Solution--------------------
http://m.baidu.com/from=844b/bd_page_type=1/ssid=0/uid=wapp_1346730378276_172/pu=sz%401320_1001%2Cusm%400/w=0_ 10_undefined+inder/t=iphone/l=3/tc?ref=www_iphone&lid=6875171567314320920&order=2&vit=osres&tj =www_normal_2_0_10&m=8&cltj=cloud_title&dict=0&sec=24536&di=dd4b5f94cbd6dcba&src=http% 3a%2f%2fwww.jb51.net%2farticle%2f30328.htm

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
  • Related Article

    Contact Us

    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.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.