Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $user_name = '';
- $user_email = '';
- $username = '';
- $password = '';
- $verify = '';
- $email = '';
- $have_error = false;
- include "validation_function.php";
- if(isset($_POST['username']) && isset($_POST['password']) && isset($_POST['verify'])){
- $user_name = $_POST['username'];
- $user_email = $_POST['email'];
- if(!valid_user_name($_POST['username'])){
- $username = "That's not a valid username.";
- $have_error = true;
- }
- if(!valid_password($_POST['password'])){
- $password = "That wasn't a valid password.";
- $have_error = true;
- }
- else if($_POST['password'] !== $_POST['verify']){
- $verify = "Your passwords didn't match.";
- $have_error = true;
- }
- if(!valid_email($_POST['email'])){
- $email = "That's not a valid email";
- $have_error = true;
- }
- if(!$have_error){
- header('Location: thanks.php?username='.$_POST['username']);
- return;
- }
- }
- ?>
- <!DOCTYPE html>
- <html>
- <head>
- <title>Sign Up</title>
- <style type="text/css">
- .label {text-align: right}
- .error {color: red}
- </style>
- </head>
- <body>
- <h2>Signup</h2>
- <form method="post">
- <table>
- <tr>
- <td class="label">
- Username
- </td>
- <td>
- <input type="text" name="username" value="<?= htmlentities($user_name)?>">
- </td>
- <td class="error">
- <?= $username ?>
- </td>
- </tr>
- <tr>
- <td class="label">
- Password
- </td>
- <td>
- <input type="password" name="password" value="">
- </td>
- <td class="error">
- <?= $password ?>
- </td>
- </tr>
- <tr>
- <td class="label">
- Verify Password
- </td>
- <td>
- <input type="password" name="verify" value="">
- </td>
- <td class="error">
- <?= $verify ?>
- </td>
- </tr>
- <tr>
- <td class="label">
- Email (optional)
- </td>
- <td>
- <input type="text" name="email" value="<?= htmlentities($user_email)?>">
- </td>
- <td class="error">
- <?= $email ?>
- </td>
- </tr>
- </table>
- <input type="submit">
- </form>
- </body>
- </html>
Add Comment
Please, Sign In to add comment