You are on page 1of 2

<?

php
require_once("functions.inc");
$a_user = &$config['captiveportal']['user'];
//print_r ($a_user);
if ($_POST) {
unset($input_errors);
$pconfig = $_POST;
/* input validation */
if ($_POST['username'] == "")
$input_errors[] = "The username is required.";
if ($_POST['password'] == "")
$input_errors[] = "The password is required.";
if (preg_match("/[^a-zA-Z0-9\.\-_]/", $_POST['username']))
$input_errors[] = "The username contains invalid characters.";
if (($_POST['password']) && ($_POST['password'] != $_POST['password2']))
$input_errors[] = "The passwords do not match.";
if (!$input_errors) {
/* make sure there are no dupes */
foreach ($a_user as $userent) {
if ($userent['name'] == $_POST['username']) {
$input_errors[] = "Another entry with the same u
sername already exists.";
break;
}
}
}
/* Save record*/
if (!$input_errors) {
$userent['name'] = $_POST['username'];
$userent['fullname'] = $_POST['fullname'];
$userent['expirationdate'] = "";//$_POST['expirationdate'];
if ($_POST['password'])
$userent['password'] = md5($_POST['password']);
$a_user[] = $userent;
write_config();
$done =1;
}

}
?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>User Registration</title>
</head>

<body>
<?php
//Success register
if (isset($done)) {
?>
<br/>
Your registration is processed. You now can login <a href="/">here</a>.
<?php
} else { //Register page
//Display Error Msg
if ($input_errors) {
echo "Error <br/>";
foreach ($input_errors as $input_error) {
echo $input_error . "<br>";
} //end foreach
} // end if
?>
<form method="post">
<table width="450" border="1">
<tr>
<td colspan="2">Registration</td>
</tr>
<tr>
<td width="132">Username</td>
<td width="302"><input type="text" name="username" id="txt_username" /></td>
</tr>
<tr>
<td>Password</td>
<td><input type="password" name="password" id="txt_pwd1" /></td>
</tr>
<tr>
<td>Verify Password </td>
<td><input type="password" name="password2" id="txt_pwd2" /></td>
</tr>
<tr>
<td>Fullname</td>
<td><input type="text" name="fullname" id="txt_name" /></td>
</tr>
<tr>
<td>&nbsp;</td>
<td><label>
<input type="submit" name="btn_submit" id="btn_submit" value="Register" />
</label></td>
</tr>
</table>
<?php
} // register page
?>
</form>
</body>
</html>

You might also like