Form validation is often seen in PHP and will be explained in this article.
The following code can implement basic form submission, user authentication.
The user name in the HTML page, PHP will be placed in $_server[' Php_auth_user ']. The password is placed in $_server[' PHP_AUTH_PW ').
Hello world, you can implement what you want to do next.
Determine the source HTTP Authentication login user
if (!isset ($_server[' Php_auth_user ')) {header ("Www-authenticate:basic realm=\" My Private area\ "); Header (" http/1.0 401 Unauthorized ");p rint" You need valid credentials to get access!\n "; exit; else {if ($_server[' php_auth_user ' = = ' admin ') && ($_server[' php_auth_pw '] = = ' qwert!@#$%12345 ')} {echo "Hello World ";} else {header ("Www-authenticate:basic realm=\" My Private area\ "); Header (" Http/1.0 401 Unauthorized ");p rint" You need Valid credentials to get access!\n "; exit;}}
This article explains the form validation knowledge, more relevant knowledge, please pay attention to the PHP Chinese web.