Header ("Location:empManage.php") page jumps to the blank page, solves, how to deal with

Source: Internet
Author: User
Tags blank page
Header ("Location:empManage.php") page jumps to a blank page, solving
loginprocess.php:


Accept user's data
1.id
$id =$_post["id"];
2. Password
$password =$_post["Password"];

To the database to verify the MySQL extension library mysqli Extension Library
1. Get Connected
$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 Database
mysql_select_db ("Empmanage", $conn) or Die (Mysql_errno ());

Send SQL statements to verify
Prevent SQL injection attacks, change validation logic
$sql = "Select password from admin where id= $id";

Obtain the password for the database by entering the ID, and then compare the password with the input.
$res =mysql_query ($sql, $conn);

if ($row = Mysql_fetch_assoc ($res)) {
Query to
Remove Database Password
if ($row ["Password"]== MD5 ($password))) {
Description Legal
Header ("Location:empManage.php");

}

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



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


/*
Simple validation (less than database)
if ($id = = "+" && $password = = "123") {
Legal, jump to empmanage.php
Header ("Location:empManage.php");
If you want to jump, it's best to exit ()
Exit ();
}else{
Illegal users
Header ("Location:login.php?errno=1");
Exit ();
}
*/
?>


Code as above, do not connect to the database can normally jump to empmanage.php
Connected to the database after the blank page, jump to the page is loginprocess.php itself, how to ah, online and other answers!!

------Solution--------------------
No output before header ();
Must be placed in front of the page head;
According to the landlord's question, check:
Whether the database can be connected properly;
The encoding is consistent;
$row ["Password"] and MD5 ($password) have equal values
------Solution--------------------
I do not see any error in the code, it is recommended that you debug first to see. Change the header () to Echo (); See if there's any output. Also, see if you have an open error prompt
------Solution--------------------
$res =mysql_query ($sql, $conn);
This sentence is not wrong.
May cause if ($row = Mysql_fetch_assoc ($res)) {There is a mistake, because the error display is not open, so it is a blank page

------Solution--------------------
Explore

$res =mysql_query ($sql, $conn);
This sentence is not wrong.
May cause if ($row = Mysql_fetch_assoc ($res)) {There is a mistake, because the error display is not open, so it is a blank page
  • 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.