The header ("Location: empManage. php") page jumps to a blank page.

Source: Internet
Author: User
Go to the blank page on the header (& quot; Location: empManage. php & quot;) page to find loginProcess. php: & lt ;? Php // accept user data // 1.id$ id =$ _ POST [& quot; id & quot;]; // 2 header ("Location: empManage. php ") jump to the blank page and solve the problem
LoginProcess. php:


// Accept user data
// 1.id
$ Id = $ _ POST ["id"];
// 2. Password
$ Password = $ _ POST ["password"];

// Go to the database to verify the mysql extension Library mysqli Extension Library
// 1. get the connection
$ Conn = mysql_connect ("localhost", "root", "root ");

If (! $ Conn ){
Die ("link failed". mysql_errno ());
}
// Set the encoding for accessing the database
Mysql_query ("set names UTF-8", $ conn) or die (mysql_errno ());
// Select a database
Mysql_select_db ("empmanage", $ conn) or die (mysql_errno ());

// Send an SQL statement for verification
// Prevents SQL injection attacks and changes the verification logic
$ SQL = "select password from admin where id = $ id ";

// Obtain the password of the database by entering the id, and then compare it with the entered password.
$ Res = mysql_query ($ SQL, $ conn );

If ($ row = mysql_fetch_assoc ($ res )){
// Query
// Retrieve the database password
If ($ row ["password"] = md5 ($ password ))){
// Valid description
Header ("Location: empManage. php ");

}

}
Header ("Location: login. php? Errno = 1 ");
Exit ();



Mysql_free_result ($ res );
Mysql_close ($ conn );


/*
// Simple verification (not available to the database)
If ($ id = "100" & $ password = "123 "){
// Valid. jump to empManage. php
Header ("Location: empManage. php ");
// If you want to jump, you 'd better exit ()
Exit ();
} Else {
// Invalid user
Header ("Location: login. php? Errno = 1 ");
Exit ();
}
*/
?>


The code is as above. if you do not connect to the database, you can jump to empManage. php normally.
A blank page is displayed after you connect to the database. the page you jump to is loginProcess. php. what is going on? online answers !!

------ Solution --------------------
No output before header;
Must be placed in front of the page HEAD;
Check whether:
Whether the database can be normally connected;
Encoding consistency;
$ Row ["password"] and md5 ($ password) have equal values
------ Solution --------------------
I didn't see any errors in the code. I suggest you debug it first. Change header () to echo () to see if there is any output. In addition, check whether you have opened the error prompt.
------ Solution --------------------
$ Res = mysql_query ($ SQL, $ conn );
This sentence is correct.
It may cause an error in if ($ row = mysql_fetch_assoc ($ res) {because the error is not displayed, it is a blank page

------ Solution --------------------
Discussion

$ Res = mysql_query ($ SQL, $ conn );
This sentence is correct.
It may cause an error in if ($ row = mysql_fetch_assoc ($ res) {because the error is not displayed, it is a blank page

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.