Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function registerform()
- {
- error_reporting(E_ALL);
- ini_set('display_errors','on');
- echo "<h1>Registration Form:</h1>\n\n"; // Form name <h1>
- echo "<form name='registration' action='"; $php_self; echo "' method='post'>\n"; // Builds the html form
- echo "<table class='formtable'>"; // Starts the beggining of the table
- if($_SERVER['REQUEST_METHOD'] == 'GET') {
- username("off");
- password("off");
- }
- elseif($_SERVER['REQUEST_METHOD'] == 'POST') {
- username("on");
- password("on");
- }
- echo "<tr>\n<td>\n</td>\n";
- echo "<td><input type='submit' value='Register'> <input type='reset' value='Reset'></td>\n</tr>\n</table></form>";
- // Creates submit button and reset button, and also closes the form and table tabs
- }
- function username($status) {
- echo "<tr>\n";
- echo "<td>Username:</p></td>\n";
- echo "<td><input type='text' name='username' value=''>";
- if($status == "on") { checkform("usercheck"); } else {}
- echo "</td>\n</tr>\n";
- }
- function password($status2) {
- echo "<tr>\n";
- echo "<td>Password:</p></td>\n";
- echo "<td><input type='password' name='password1'></td>\n";
- echo "</tr>\n";
- echo "<tr>\n";
- echo "<td>Re-Type Password:</p></td>\n";
- echo "<td><input type='password' name='password2'>";
- if($status2 == "on") { checkform("passcheck"); } else {}
- echo "</td>\n</tr>\n";
- }
- function checkform($checktype){
- switch($checktype)
- {
- case "usercheck" :
- $username = $_POST['username'];
- if(!(isset($username) && (strlen($username) > 2) && (strlen($username) < 20) && (ctype_alpha($username)))) {
- $errors['username'] = '<br>Username needs to be over 2 letters long and can only contain the letters A-Z';
- echo $errors['username'];
- }
- break;
- case "passcheck" :
- $pass1 = $_POST['password1']; // Get password1 submitted from form
- $pass2 = $_POST['password2']; // Get password2 submitted from form
- if($pass1 == $pass2)
- {
- if(!(isset($pass1) && (strlen($pass1) > 2) && (strlen($pass1) < 20) && (ctype_alpha($pass1))))
- {
- $errors['password'] = '<br>Password needs to be over 2 letters long and can only contain the letters A-Z';
- //echo $errors['password'];
- }
- else {
- $errors['password'] = '<br>Passwords Match!';
- }
- }
- else
- {
- $errors['password'] = '<br>Passwords Did not Match!';
- //echo $errors['password'];
- }
- echo $errors['password'];
- break;
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement