function register_user() { $username = $_POST["username"]; $email = $_POST["email"]; $password = $_POST["password"]; $captcha = trim($_POST["captcha"]); //if not valid captcha() include_once "/var/www/includes/captch_code.php"; if (check_code($captcha)) { //sanitize input fields; $cr = new crypto(); $password_hash = $cr->one_way_crypt($password); //add new user to database $u = new user(); try { if ($u->create_user($username, $password_hash, $email)) { $uid = $u->get_user_id($email); $token = base64_encode($cr->encrypt($uid)); //send activation email $link = "http://punbt090pc/activate.php?u=" . urlencode($token); include_once "/var/www/includes/email.php"; send_activation_email($email, $link); set_registration_error("An activation email has been sent to your inbox (Please check your junkbox in case you have not received it)."); } else { //send back to registration page header("Location: /register.php"); } } catch (Exception $e) { set_registration_error("UserName Or Email is already registered"); } } else { set_registration_error("Invalid Captcha"); } }
<header> <div id="logo"> <div id="logo_text"> <!-- class="logo_colour", allows you to change the colour of the text --> <h1><a href="index.php">HackWeek<span class="logo_colour">#hackTheFlag</span></a></h1> <h2>Hack like ninja!, play for pride, fun and prizes!</h2> </div> </div> <nav> <?php include_once "/var/www/includes/error.php"; $msg = get_registration_error(); if ($msg != '') { set_registration_error(""); ?> <div id="menu_container"> <center><h3 id="err_msg" style="color: red"><?php echo $msg; ?> </h3></center> </div> <?php } else { ?> <div id="menu_container"> <center><h3 id="err_msg" style="color: red"></h3></center> </div> <?php }