How do you write the code that the user logged in to handle?

Source: Internet
Author: User
User Login processing code how to write Ah.
Session_Start ();
?>
"Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" >



/>
<title></title>


Header ("Content-type:text/html;charset=utf-8");
Connecting to a database
mysql_connect ("localhost", "root", "");
mysql_select_db ("db12");
/** The purpose of the file is to receive user input information, to query, to determine if there is, if stored
In the jump to the Success page, if the error, give an error prompt. */
Accept user parameters (user name, password)
$user =$_post[' username '];
$pass =$_post[' password '];
Query according to user name, take out password
$sql = "Select password from tb_user where Username= '". $user. "'";

Execute Query
$rs =mysql_query ($sql);
if ($rs! = "") {
$selpass =mysql_result ($rs, 0);
}
if ($selpass! = ") {
Determine if the password taken is consistent with user input
if ($pass = = $selpass) {
$_session[' username ']= $user;
?>

}else{
Prompt for password error
?>

}
}else{
If the information is not queried according to the user name, the user name does not exist
?>

}
?>


The above is written to handle the user login code,
Why this is shown on the login screen regardless of whether the correct or incorrect information is entered:


------Solution--------------------
Print_r () your username and password don't know what's going on!
------Solution--------------------
Why not? Your second form has no username and password controls at all, and of course it's an error.
Print_r ($_post); It's clear.
  • 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.