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!