How do you make a secure Login using PHP? 
Login?
The below script is a simple miltiuser login
| Quote: | ||
|
| mathiaus wrote: |
| Please quote copied code and credit source
http://www.collingwood2000.karoo.net/tutorials/php/multiuser/index.php |
But all time you request a page from server, you send your password in cleartext
its not good idea and you can use http 401 unauthorized insted
It is secure as the solution before
but it don't mean that I recommend this solution
its not good idea and you can use http 401 unauthorized insted
| Code: |
|
<?php $givenpassword = $PHP_AUTH_PW; switch ($PHP_AUTH_USER){ case "user1": $password = "pass1"; break; case "user2": $password = "pass2"; break; case "admin": $password = "adminpass"; break; default: $password = "no"; $givenpassword = "yes"; } if ($givenpassword != $password) { Header("WWW-Authenticate: Basic realm=\"My Realm\""); Header("HTTP/1.0 401 Unauthorized"); ?> <h1>Please Login with correct username and password</h1> <? exit; } else { ?> ENTER PROTECTED CONTENT HERE <? } ?> |
It is secure as the solution before
but it don't mean that I recommend this solution
Personally you guys seem to be making things complex... anyway in referance to This piece of code
Why not simply have
Shorter and does the same thing.. you only need to use action="x.php" if you are sending the data to another page or you need it to load up a variable page such as members.php?page=somepage
| Code: |
| <form name="form" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>"> |
Why not simply have
| Code: |
| <form method="post"> |
Shorter and does the same thing.. you only need to use action="x.php" if you are sending the data to another page or you need it to load up a variable page such as members.php?page=somepage
| Quote: |
| Shorter and does the same thing.. you only need to use action="x.php" if you are sending the data to another page or you need it to load up a variable page such as members.php?page=somepage |
You also need to use 'action=' if you want to make your pages html/xhtml compliant according to the W3C specifications.
Yeah well.. you have to be painstackingly precise if you wanna make things fully WC3 XHTML compliant...
