Here is my register.tpl
Still need to clean up most code though it is working for me (no mailing function included.)
PHP Code:
<?php
$page = 'register';
include(ROOT.'/inc/functions/register.php');
GLOBAL $txt;
GLOBAL $lang;
GLOBAL $_SESSION;
#Goeie taal erbij laden voor de page
$foutje1 = '';
$foutje2 = '';
$foutje3 = '';
$foutje4 = '';
$foutje5 = '';
$foutje6 = '';
$foutje7 = '';
$foutje8 = '';
$foutje9 = '';
$foutje10 = '';
$foutje11 = '';
$foutje12 = '';
$grefer = '';
if(isset($_GET['referer'])){
$grefer = $_GET['referer'];
}
if(isset($_POST['registreer'])){
$voornaam = $_POST['voornaam'];
$achternaam = $_POST['achternaam'];
$land = $_POST['land'];
$gebdate = $_POST['year'].'-'.$_POST['month'].'-'.$_POST['day'];
$inlognaam = $_POST['inlognaam'];
$wachtwoord = $_POST['wachtwoord'];
$wachtwoord_nogmaals = $_POST['wachtwoord_nogmaals'];
$wachtwoordmd5 = md5($wachtwoord);
$email = $_POST['email'];
$wereld = $_POST['wereld'];
$captcha = $_POST['captcha'];
$ip = $_SERVER['REMOTE_ADDR'];
$date = date("Y-m-d H:i:s");
$character = $_POST['character'];
$referer = $_POST['referer'];
$check = validate_ip($ip);
$registerdate = strtotime($check['aanmeld_datum']);
$current_time = strtotime(date('Y-m-d H:i:s'));
$countdown_time = 604800-($current_time-$registerdate);
if(isset($_SESSION['captcha_code'])){
$captcha_code = $_SESSION['captcha_code'];
}else{
$captcha_code = 0;
}
if(isset($_POST['agreecheck'])){
$secondaccount = $_POST['agreecheck'];
}else{
$secondaccount = false;
}
if(($check['ip_aangemeld'] == $ip) && ($countdown_time > 0)){
$alert = '<div class="red">'.$txt['alert_already_this_ip'].'</div>';
}
if(empty($voornaam)){
$foutje1 = '<span class="error_red">*</span>';
$alert = '<div class="red">'.$txt['alert_no_firstname'].'</div>';
}elseif(strlen($voornaam) > 12 ){
$foutje1 = '<span class="error_red">*</span>';
$alert = '<div class="red">'.$txt['alert_firstname_too_long'].'</div>';
}
elseif(empty($achternaam)){
$foutje2 = '<span class="error_red">*</span>';
$alert = '<div class="red">'.$txt['alert_no_lastname'].'</div>';
}
elseif(strlen($achternaam) > 12 ){
$foutje1 = '<span class="error_red">*</span>';
$alert = '<div class="red">'.$txt['alert_lastname_too_long'].'</div>';
}
elseif(empty($land)){
$foutje3 = '<span class="error_red">*</span>';
$alert = '<div class="red">'.$txt['alert_no_country'].'</div>';
}
elseif(($_POST['day'] == '0') OR ($_POST['month'] == '0') OR ($_POST['year'] == '0')){
$foutje4 = '<span class="error_red">*</span>';
$alert = '<div class="red">'.$txt['alert_no_full_gebdate'].'</div>';
}
elseif(empty($inlognaam)){
$foutje5 = '<span class="error_red">*</span>';
$alert = '<div class="red">'.$txt['alert_no_username'].'</div>';
}
elseif(strlen($inlognaam) < 3 ){
$foutje5 = '<span class="error_red">*</span>';
$alert = '<div class="red">'.$txt['alert_username_too_short'].'</div>';
}
elseif(strlen($inlognaam) > 10 ){
$foutje5 = '<span class="error_red">*</span>';
$alert = '<div class="red">'.$txt['alert_username_too_long'].'</div>';
}
elseif(validate_username($inlognaam) >= 1){
$foutje5 = '<span class="error_red">*</span>';
$alert = '<div class="red">'.$txt['alert_username_exists'].'</div>';
}
elseif(!preg_match('/^([a-zA-Z0-9]+)$/is', $inlognaam)){
$foutje5 = '<span class="error_red">*</span>';
$alert = '<div class="red">'.$txt['alert_username_incorrect_signs'].'</div>';
}
elseif(empty($wachtwoord)){
$foutje6 = '<span class="error_red">*</span>';
$alert = '<div class="red">'.$txt['alert_no_password'].'</div>';
}
elseif($wachtwoord <> $wachtwoord_nogmaals){
$foutje6 = '<span class="error_red">*</span>';
$foutje7 = '<span class="error_red">*</span>';
$alert = '<div class="red">'.$txt['alert_passwords_dont_match'].'</div>';
}
elseif(empty($email)){
$foutje8 = '<span class="error_red">*</span>';
$alert = '<div class="red">'.$txt['alert_no_email'].'</div>';
}
elseif(!preg_match("/^[A-Z0-9._%-]+@[A-Z0-9][A-Z0-9.-]{0,61}[A-Z0-9]\.[A-Z]{2,6}$/i", $email)){
$foutje8 = '<span class="error_red">*</span>';
$alert = '<div class="red">'.$txt['alert_email_incorrect_signs'].'</div>';
}
elseif(validate_email($email) >= 1){
$foutje8 = '<span class="error_red">*</span>';
$alert = '<div class="red">'.$txt['alert_email_exists'].'</div>';
}
elseif($character != 'Red' && $character != 'Leaf' && $character != 'Ethan' && $character != 'Lyra' && $character != 'Brendan' && $character != 'May' && $character != 'Lucas' && $character != 'Dawn' && $character != 'Lunick' && $character != 'Solana' && $character != 'Ash' && $character != 'Blue' && $character != 'Brock' && $character != 'Misty' && $character != 'Tracey' && $character != 'Max' && $character != 'Paul' && $character != 'J'){
$foutje9 = '<span class="error_red">*</span>';
$alert = '<div class="red">'.$txt['alert_character_invalid'].'</div>';
}
elseif(empty($wereld)){
$foutje10 = '<span class="error_red">*</span>';
$alert = '<div class="red">'.$txt['alert_no_beginworld'].'</div>';
}
elseif($wereld != 'Kanto' && $wereld != 'Johto' && $wereld != 'Hoenn' && $wereld != 'Sinnoh' && $wereld != 'Unova'){
$foutje10 = '<span class="error_red">*</span>';
$alert = '<div class="red">'.$txt['alert_world_invalid'].'</div>';
}
elseif($secondaccount != True){
$foutje11 = '<span class="error_red">*</span>';
$alert = '<div class="red">'.$txt['alert_1account_condition'].'</div>';
}
elseif($captcha != $captcha_code){
$foutje12 = '<span class="error_red">*</span>';
$alert = '<div class="red">'.$txt['alert_guardcore_invalid'].'</div>';
}else{
$activatiecode = rand(111111,999999);
register_user($activatiecode, $voornaam, $achternaam, $land, $character, $inlognaam, $gebdate, $date, $wachtwoordmd5, $email, $ip, $wereld, $referer);
$page = 'register';
#Goeie taal erbij laden voor de mail
#include_once('language/language-mail.php');
$alert = '<div class="green">'.$txt['success_register'].'</div>';
}
}
?>
<form method="post" action="?page=register" name="register">
<center><p><img src="http://forum.ragezone.com/images/icons/ster.png" /> <?php echo $txt['title_text']; ?> <img src="http://forum.ragezone.com/images/icons/ster.png" /></p></center>
<?php if(!empty($alert)){ echo $alert; } ?>
<table width="660" cellspacing="0" cellpadding="0">
<tr><td colspan="2" class="top_first_td"><?php echo $txt['register_personal_data']; ?></td></tr>
<tr><td colspan="2" style="padding-bottom:10px;"></td></tr>
<tr>
<td width="200" class="normal_first_td"><?php echo $txt['firstname'].' '.$foutje1; ?></td>
<td width="460" class="normal_td"><input type="text" name="voornaam" value="<?php if(isset($_POST ['voornaam']) && !empty($_POST ['voornaam'])) { echo $_POST ['voornaam']; }?>" class="text_long" maxlength="12"></td>
</tr>
<tr>
<td class="normal_first_td"><?php echo $txt['lastname'].' '.$foutje2; ?></td>
<td class="normal_td"><input type="text" name="achternaam" value="<?php if(isset($_POST ['achternaam']) && !empty($_POST ['achternaam'])) { echo $_POST ['achternaam']; }?>" class="text_long" maxlength="12"></td>
</tr>
<tr>
<td class="normal_first_td"><?php echo $txt['country'].' '.$foutje3; ?></td>
<td class="normal_td"><select name="land" value="<?php if(isset($_POST ['land']) && !empty($_POST ['land'])) { echo $_POST ['land']; }?>" class="text_select">
<?php
$query = 'SELECT en, nl FROM landen';
$landsql = Core::$DB->prepare($query)->execute();
if(isset($_POST['land'])){
$landd = $_POST['land'];
}else{
$landd = $lang['taalgeneral'];
}
while($land = $landsql->fetch_assoc()){
if($land['en'] == $landd){
$selected = 'selected';
}else{
$selected = '';
}
echo '<option value="'.$land['en'].'" '.$selected.'>'.$land[$lang['taalshort']].'</option>';
}
?>
</select>
</td>
</tr>
<tr>
<td class="normal_first_td"><?php echo $txt['gebdate'].' '.$foutje4; ?></td>
<td class="normal_td">
<?php
echo '<select name="day" class="text_select">
<option value="0">'.$txt['day'].'</option>';
for ($i = 1; $i <= 31; $i++) {
$selected = isset($_POST['day']) && $_POST['day'] == $i ? ' selected="selected"' : '';
echo '<option value="'.$i.'"'.$selected.'>'.$i.'</option>';
}
echo '</select>';
echo '<select name="month" class="text_select">
<option value="0">'.$txt['month'].'</option>';
for ($i = 1; $i <= 12; $i++) {
$selected = isset($_POST['month']) && $_POST['month'] == $i ? ' selected="selected"' : '';
echo '<option value="'.$i.'"'.$selected.'>'.strftime('%B', mktime(0, 0, 0, $i, 1)).'</option>';
}
echo '</select>';
echo '<select name="year" class="text_select">
<option value="0">'.$txt['year'].'</option>';
for ($i = 2010; $i >= 1975; $i--) {
$selected = isset($_POST['year']) && $_POST['year'] == $i ? ' selected="selected"' : '';
echo '<option value="'.$i.'"'.$selected.'>'.$i.'</option>';
}
echo '</select>';
?>
</td>
</tr>
<tr><td colspan="2" style="padding-top:10px;"></td></tr>
<tr><td colspan="2" class="top_first_td"><?php echo $txt['register_game_data']; ?></td></tr>
<tr><td colspan="2" style="padding-bottom:10px;"></td></tr>
<tr>
<td class="normal_first_td"><?php echo $txt['username'].' '.$foutje5; ?></td>
<td class="normal_td"><input name="inlognaam" type="text" class="text_long" value="<?php if(!empty($_POST ['inlognaam'])) { echo $_POST ['inlognaam']; }?>" maxlength="10" /></td>
</tr>
<tr>
<td class="normal_first_td"><?php echo $txt['password'].' '.$foutje6; ?></td>
<td class="normal_td"><input type="password" name="wachtwoord" value="<?php if(!empty($_POST ['wachtwoord'])) { echo $_POST ['wachtwoord']; }?>" class="text_long" /></td>
</tr>
<tr>
<td class="normal_first_td"><?php echo $txt['password_again'].' '.$foutje7; ?></td>
<td class="normal_td"><input type="password" name="wachtwoord_nogmaals" value="<?php if(!empty($_POST ['wachtwoord_nogmaals'])) { echo $_POST ['wachtwoord_nogmaals']; }?>" class="text_long" /></td>
</tr>
<tr>
<td class="normal_first_td"><?php echo $txt['email'].' '.$foutje8; ?></td>
<td class="normal_td"><input type="text" name="email" value="<?php if(!empty($_POST ['email'])) { echo $_POST ['email']; }?>" class="text_long" /></td>
</tr>
<tr>
<td class="normal_first_td"><?php echo $txt['character'].' '.$foutje9; ?></td>
<td class="normal_td"><select name="character" value="<?php if(!empty($_POST ['character'])) { echo $_POST ['character']; }?>" class="text_select">
<?php
$query = 'SELECT naam FROM characters ORDER BY id ASC';
$charactersql = Core::$DB->prepare($query)->execute();
if(isset($_POST['character'])){
$characterr = $_POST['character'];
}else{
$characterr = 'Red';
}
while($character = $charactersql->fetch_assoc()){
if($character['naam'] == $characterr){
$selected = 'selected';
}else{
$selected = '';
}
echo '<option value="'.$character['naam'].'" '.$selected.'>'.$character['naam'].'</option>';
}
?>
</select>
</td>
</tr>
<tr>
<td class="normal_first_td"><?php echo $txt['beginworld'].' '.$foutje10; ?></td>
<td class="normal_td">
<select name="wereld" class="text_select">
<option <?php if(isset($_POST['wereld']) && $_POST['wereld'] == "Kanto") { echo 'checked'; } ?>>Kanto</option>
<option <?php if(isset($_POST['wereld']) && $_POST['wereld'] == "Kanto") { echo 'checked'; } ?>>Johto</option>
<option <?php if(isset($_POST['wereld']) && $_POST['wereld'] == "Kanto") { echo 'checked'; } ?>>Hoenn</option>
<option <?php if(isset($_POST['wereld']) && $_POST['wereld'] == "Kanto") { echo 'checked'; } ?>>Sinnoh</option>
<option <?php if(isset($_POST['wereld']) && $_POST['wereld'] == "Unova") { echo 'checked'; } ?>>Unova</option>
</select>
</td>
</tr>
<tr>
<td class="normal_first_td"><label for="agreecheck"><?php echo $txt['1account_rule']; ?></label><?php echo $foutje11; ?></td>
<td class="normal_td"><input name="agreecheck" id="agreecheck" value="yes" type="checkbox" <?php if(isset($_POST['agreecheck']) && $_POST['agreecheck'] == "yes") { echo 'checked'; } ?>></td>
</tr>
<tr>
<td class="normal_first_td"><?php echo $txt['referer']; ?></td>
<td class="normal_td"><input type="text" name="referer" value="<?php echo $grefer; ?>" class="text_long" /> <span style="padding-left:5px;"><?php echo $txt['not_oblige']; ?></span></td>
</tr>
<tr>
<td colspan="2" style="padding-bottom:10px;"></td>
</tr>
<tr>
<td colspan="2" class="top_first_td"><?php echo $txt['register_security']; ?></td>
</tr>
<tr>
<td colspan="2" style="padding-bottom:10px;"></td>
</tr>
<tr>
<td class="normal_first_td"> </td>
<td class="normal_td"><img src="inc/captcha.inc.php" alt="<?php echo $txt['captcha']; ?>" title="<?php echo $txt['captcha']; ?>" /></td>
</tr>
<tr>
<td class="normal_first_td"><?php echo $txt['guardcode'].' '.$foutje12; ?></td>
<td class="normal_td"><input name="captcha" type="text" class="text_long" maxlength="3" /></td>
</tr>
<tr>
<td class="normal_first_td"> </td>
<td class="normal_td"><input type="submit" value="<?php echo $txt['button']; ?>" name="registreer" class="button"></td>
</tr>
</table>
</form>
<?php session_destroy(); ?>