Html login jumps to the php page to connect to the database, prompting that the submission is not successful

Source: Internet
Author: User
The html login jumps to the php page to connect to the database and prompts that the submission is unsuccessful. this is the form in HTML:






This is the php login connection database php:
If (isset ($ _ POST ["submit"]) & $ _ POST ["submit"] = "login ")
{
$ User = $ _ POST ["username"];
$ Psw = $ _ POST ["password"];
If ($ user = "" | $ psw = "")
{
Echo "script" alert ('Enter your username or password! '); History. go (-1); script ";
}
Else
{
$ Con = mysql_connect ("Wagner. 0.0.1", "root", "1234 ");
If (! $ Con)
{
Die ('could not connect: '. mysql_error ());
}
Mysql_select_db ("vote ");
Mysql_query ("set names 'utf-8 '");
$ SQL = "select username from password table where username = '$ _ POST [username]' and password = '$ _ POST [password]'";
$ Result = mysql_query ($ SQL );
If ($ result)
{
Echo $ username, 'Welcome! Go to User Center
';
}
Else
{
Echo "script alert ('The user name or password is incorrect! '); History. go (-1); script ";
}
}
}
Else
{
Echo "script alert ('submission failed! '); History. go (-1); script ";
}
?>


Reply to discussion (solution)

Isset ($ _ POST ["submit"])
This phpif condition is empty and does not enter the php program. but isn't it passed a value in form?

Print $ _ POST ["submit"] to see what it is.

The form cannot be submitted. change the button to input.


$ _ POST ["submit"] = "login"
When the form and handler are not in the same file, there is a certain risk of such judgment.
The encoding of the two files must be consistent!

$ _ POST ["submit"] = "login"


Print $ _ POST ["submit"] to see what it is.




Is it useless to change to input?

I don't know what's going on. it's successful... Thank you!

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.