Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- <title>Mismatch - Sign Up</title>
- <meta charset="utf-8">
- </head>
- <body>
- <?php
- require_once('appvars.php');
- require_once('connectvars.php');
- // Connect to the database
- $dbc = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
- if(isset($_POST['submit'])
- {
- // Grab the profile data from POST
- $username = $_POST['username']);
- $password1 = $_POST['password1']);
- $password2 = $_POST['password2']);
- if(!empty($username) && !empty($password1) && !empty($password2) &&
- ($password1 == $password2) )
- {
- // Make sure someone isn't already registered with this username
- $query = "SELECT * FROM mismatch_user WHERE username = '$username'";
- $data = mysqli_query($dbc, $query);
- if(mysqli_num_rows($data) == 0)
- {
- // The username is unique, so insert the data into the database
- $query = "INSERT INTO mismatch_user (username, password, date) VALUES" .
- "('$username', SHA('$password1'), NOW())";
- mysqli_query($dbc, $query);
- // Confirm success with the user
- echo '<p>Your new account has been successfully created. You\'re ready to log in and ' .
- '<a href="editprofile.php">edit your profile</a>.</p>';
- mysqli_close($dbc);
- exit();
- }
- else
- {
- // An account already exists for this username, so display an error message
- echo '<p class="error">An account already exists for this username. ' .
- 'Please use a different address.</p>';
- $username = "";
- }
- }
- else
- {
- echo '<p class="error">You must enter all of the sign-up data, ' .
- 'including the desired password twice.</p>';
- }
- }
- ?>
- <p>Please enter you username and desired password to sign up to Mismatch.</p>
- <form method="post" action="<?php echo $_SERVER['PHP_SELF']?>">
- <fieldset>
- <legend>Registration Info</legend>
- <label for="username">Username:</label>
- <input type="text" id="username" name="username" value="<?php if(!empty($username)) echo $username;?>"><br>
- <label for="password1">Password:</label>
- <input type="password" id="password1" name="password1" value="<?php if(!empty($password1)) echo $password1;?>"><br>
- <label for="password2">Password (retype):</label>
- <input type="password" id="password2" name="password2"><br>
- </fieldset>
- </form>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement