Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- include("globals/layout/header.php");
- $beta_on = 1;
- if(isset($_POST['register'])) {
- // grab form data
- $login_name = mysqli_real_escape_string(strip_tags($db, $_POST['login']));
- $username = mysqli_real_escape_string(strip_tags($db,$_POST['username']));
- $password = mysqli_real_escape_string(strip_tags($db, $_POST['password']));
- $password_again = mysqli_real_escape_string(strip_tags($db, $_POST['password_again']));
- $email = mysqli_real_escape_string(strip_tags($db, $_POST['email']));
- $birthdate = mysqli_real_escape_string(strip_tags($db, $_POST['date_month']) . '/' . mysqli_real_escape_string(strip_tags($db,($_POST['date_day'])) . '/' . mysqli_real_escape_string(strip_tags($db, $_POST['date_year']));
- $bday = mysqli_real_escape_string(strip_tags($db, $_POST['date_year'])) . '/' . mysqli_real_escape_string(strip_tags($db, $_POST['date_month'])) . '/' . mysqli_real_escape_string(strip_tags($db,$_POST['date_day']));
- $age = calculateAge($bday);
- $ip = $_SERVER['REMOTE_ADDR'];
- $registered = date("Y-m-d H:i:s");
- $security_q = mysqli_real_escape_string(strip_tags($db, $_POST['security_q']));
- $security_a = mysqli_real_escape_string(strip_tags($db,$_POST['security_a']));
- $access_code = mysqli_real_escape_string(strip_tags($db,$_POST['access_code']));
- if($beta_on = 1) {
- $beta = 'Yes';
- } else {
- $beta = 'No';
- }
- $login_check = mysqli_num_rows(mysqli_query($db, "SELECT `id` FROM users WHERE `login_name`='".$login_name."' LIMIT 1"));
- $email_check = mysqli_num_rows(mysqli_query($db, "SELECT * FROM users WHERE `user_email`='".$email."'"));
- $access_check = mysqli_num_rows(mysqli_query($db, "SELECT * FROM users WHERE `access_code`='".$access_code."'"));
- // set options for password_hash
- $options = array(
- 'cost' => 12,
- );
- $hashed_password = password_hash($password, PASSWORD_BCRYPT, $options);
- // check that all fields are filled out
- if(empty($login_name) || empty($username) || empty($password) || empty($password_again) || empty($email) || empty($birthdate) || empty($access_code)) {
- echo $fill_all;
- // verify that access code is correct
- } else if(!$access_code) {
- echo $access_code_incorrect;
- // verify that passwords match
- } else if($password != $password_again) {
- echo $invalid_pass_match;
- // verify that login name is unique
- } else if ($login_check) {
- echo $login_name_not_unique;
- // verify that email has only been used three times maximum
- } else if ($email_check > 3) {
- echo $email_used_x3;
- // verify that the user is older than 13 years old from birthdate
- } else if ($age < 13) {
- echo $too_young;
- // if all checks pass, register user
- } else {
- $query = "UPDATE users SET login_name ='".$login_name."', username = '".$username."', password='".$hashed_password."', user_email='".$email."', user_birthdate='".$birthdate."', user_age='".$age."', ip_address='".$ip."', beta='".$beta."', join_date='".$registered."', security_question='".$security_q."', security_answer='".$security_a."' WHERE `access_code` = '".$access_code."'";
- mysqli_query($db, $query);
- echo $registration_complete;
- }
- }
- //calculate age of user
- function calculateAge($bday) {
- $birth = strtotime($bday);
- $ageStamp = time() - $birth;
- $year = 60 * 60 * 24 * 365; // not accounting for leap year!!!
- return floor($ageStamp / $year);
- }
- ?>
- <div class="formLayout">
- <h2>Come Join Us In Eqcetera v2.0!</h2>
- <div class="formLayout-body">
- <form action="" method="post">
- <!-- USERNAME FIELD -->
- <label for="username">Username: <span style="font-size:smaller;">(what other's will know you as)</span></label>
- <input class="login_input" type="text" name="username" id="username" autocomplete="off" ><br />
- <!-- LOGIN NAME FIELD -->
- <label for="login">Login Name: <span style="font-size:smaller;">(only letters and numbers, 3 to 64 characters, must be unique)</span> </label>
- <input class="login_input" type="text" pattern="[a-zA-Z0-9]{3,64}" name="login" id="login" autocomplete="off" required="" ><br />
- <!-- PASSWORD FIELD -->
- <label for="password">Password: <span style="font-size:smaller;">(min. 6 characters)</span> </label>
- <input class="login_input" type="password" name="password" id="password" pattern="{4,64}" autocomplete="off" required=""><br />
- <!-- PASSWORD AGAIN FIELD -->
- <label for="password_again">Password Again: </label>
- <input class="login_input" type="password" name="password_again" pattern="{4,64}" id="password_again" autocomplete="off" required=""><br />
- <!-- EMAIL FIELD -->
- <label for="email">Valid Email: </label>
- <input class="login_input" type="email" name="email" id="email" autocomplete="off" required=""><br />
- <!-- ACCESS CODE FIELD -->
- <label for="access_code">v2.0 BETA Access Code: </label>
- <input class="login_input" type="text" name="access_code" id="access_code" autocomplete="off" required=""><br />
- <!-- BIRTHDATE FIELD -->
- <?php
- $year_limit = '13';
- $html_output = ' <label for="birth_date">Date of Birth:</label> ';
- /*months*/
- $html_output .= '<select name="date_month" id="month_select" required >';
- $months = array("", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");
- for ($month = 1; $month <= 12; $month++) {
- if($month <= 9)
- {
- $month_o = "0".$month;
- }
- else if($month >= 10) {
- $month_o = $month;
- }
- $html_output .= ' <option value="' . $month_o . '">' . $months[$month] . '</option>';
- }
- $html_output .= ' </select>'."\n";
- /*days*/
- $html_output .= ' <select name="date_day" id="day_select">';
- for ($day = 1; $day <= 31; $day++) {
- if($day < 10)
- {
- $day = "0".$day;
- }
- $html_output .= ' <option>' . $day . '</option>';
- }
- $html_output .= ' </select>'."\n";
- /*years*/
- $html_output .= ' <select name="date_year" id="year_select">';
- for ($year = 1945; $year <= (date("Y") - $year_limit); $year++) {
- $html_output .= ' <option>' . $year . '</option>';
- }
- $html_output .= ' </select> <br> ';
- echo $html_output;
- ?>
- <p align="center" style="font-size:15px;"><i>You will need to set a security question and answer. <br />This can be changed later and is used to reset your account <br />if you should lose the information.</i></p>
- <!-- SECURITY QUESTION FIELD -->
- <label for="security_q">Security Question: </label>
- <input class="login_input" type="text" name="security_q" id="security_q" autocomplete="off" required=""><br />
- <!-- SECURITY ANSWER FIELD -->
- <label for="security_a">Security Answer: </label>
- <input class="login_input" type="text" name="security_a" id="security_a" autocomplete="off" required=""><br />
- <!-- SUBMIT BUTTON -->
- <div class="button-holder"><input type="submit" name="register" value="Register!" /> </div>
- </form>
- </div>
- </div>
- <?php
- // include footer file
- include("globals/layout/footer.php");
- ?>
Add Comment
Please, Sign In to add comment