<html>
<head>
<title>Signup</title>
<body>
<?php
if ($submit) //if the form has been submitted
{
if (!$nick || !$email || !$password || !$password2)
//if any of the fields were not filled in
{
$error = "All fields are required. Check input and try again"; //set error
} else {
if ($password != $password2) //if the passwords do not match
{
$error = "Passwords do not match."; //set error
} else //if everything went smoothly
{ //process form
$fp = fopen("/home/yournick/.htpasswd", "a");
//open file, chage this to the path
//to your .htpasswd. The "a" means to
//"append" to the end of the file.
fwrite($fp, "$nick:" . crypt($password) . "\
"); //write to the htpasswd file
fclose($fp);
?>
Information successfully entered. You are now registered.
<?php
}
}
}
if (!$submit || $error)
//if the form has NOT been submitted or if there is an error
{
//display form
?>
<br>
<?php if ($error){ printf("<font color=FF0000>%s</font>\
", $error); } ?> <!--
//if there is an error print it -->
<form method="post" action="<?php echo $PHP_SELF?>">
Nick:<input type="Text" name="nick" maxlength="25" width="25"
<?php if ($nick){ printf("value=%s", $nick);}?>><br>
E-mail:<input type="Text" name="email" maxlength="50" width="25"
<?php if ($email){ printf("value=%s", $email);}?>><br>
Password:<input type="Password" name="password" maxlength="25" width="25"><br>
Password again:<input type="Password" name="password2" maxlength="25" width="25"><br>
<input type="submit" name="submit" value="Join">
</form>
<?php
} //end if statement
?>
</body>
</html>