Revision: 49032
Updated Code
at July 14, 2011 07:21 by hairzo
Updated Code
<?php
// - - - - - - - - - - - - - - - - - - -
// Author: Christopher Hair
// Website: www.chrishair.co.uk
// - - - - - - - - - - - - - - - - - - -
if (isset($_POST['submit'])){
$error = '';
$username = trim(stripslashes($_POST['username']));
$password = trim(stripslashes($_POST['password']));
if ($username == '' || preg_match('/\s/m', $username)) {
$error .= "<p><strong>Invalid Username.</strong></p>\n";
}
if ($password == '' || preg_match('/\s/m', $password)) {
$error .= "<p><strong>Invalid Password.</strong></p>\n";
}
if ($error == '') {
echo "<p>Success</p>\n";
echo "<h1>" . htmlspecialchars($username) . ":" . crypt($password) . "</h1>\n";
} else {
echo $error;
}
}
?>
Revision: 49031
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at July 14, 2011 07:18 by hairzo
Initial Code
<?php
// - - - - - - - - - - - - - - - - - - -
// Author: Christopher Hair
// Website: www.chrishair.co.uk
// - - - - - - - - - - - - - - - - - - -
if (isset($_POST['submit'])){
$error = '';
$username = trim(stripslashes($_POST['username']));
$password = trim(stripslashes($_POST['password']));
if ($username == '' || preg_match('/\s/m', $username)) {
$error .= "<p><strong>Invalid Username.</strong></p>\n";
}
if ($password == '' || preg_match('/\s/m', $password)) {
$error .= "<p><strong>Invalid Password.</strong></p>\n";
}
if ($error == '') {
echo "<p>Success</p>\n";
echo "<h1>" . htmlspecialchars($username) . ":" . crypt($password) . "</h1>\n";
} else {
echo $error;
}
}
?>
Initial URL
http://www.chrishair.co.uk/supgha/
Initial Description
Created by me as a quick and secure way of creating a username and password for basic authentication via a .htpasswd file on an Apache server. A live demo is available at http://www.chrishair.co.uk/supgha/ Thanks.
Initial Title
Username and password generator for .htpasswd files
Initial Tags
php, htaccess, apache
Initial Language
PHP