<?php include('inc/header.php'); ?> <h1 id="Heading">Ingame Registration</h1>
<?php
if(!isset($_POST['reg_username'])) $_POST['reg_username'] = '';
if(!isset($_POST['reg_email'])) $_POST['reg_email'] = '';
odbc_exec($mssql, 'USE [ACCOUNT_DBF]');
$checkacc = odbc_exec($mssql, 'SELECT COUNT(*) as count FROM [ACCOUNT_TBL] WHERE account=\''.mssql_escape_string($_POST['reg_username']).'\'');
$checkmail = odbc_exec($mssql, 'SELECT COUNT(*) as count FROM [ACCOUNT_TBL_DETAIL] WHERE email=\''.mssql_escape_string($_POST['reg_email']).'\'');
$errors = array();
if(empty($_POST['reg_username']) || empty($_POST['reg_password']) || empty($_POST['reg_confirmpw']) || empty($_POST['reg_email']) || empty($_POST['reg_captcha']))
$errors[] = 'You must fill in all fields!';
if(!empty($_POST['reg_username']) && odbc_result($checkacc, 'count') > 0)
$errors[] = 'The username already exists!';
if(!empty($_POST['reg_email']) && odbc_result($checkmail, 'count') > 0)
$errors[] = 'The e-mail address already exists!';
if(!empty($_POST['reg_username']) && (strlen($_POST['reg_username']) > 10 || strlen($_POST['reg_username']) < 4))
$errors[] = 'Your username must be 4 - 10 characters included!';
if(!empty($_POST['reg_password']) && (strlen($_POST['reg_password']) > 12 || strlen($_POST['reg_password']) < 6))
$errors[] = 'Your password must be 6 - 12 characters included!';
if((!empty($_POST['reg_password']) && !empty($_POST['reg_confirmpw'])) && $_POST['reg_password'] != $_POST['reg_confirmpw'])
$errors[] = 'Repeat your password is wrong!';
if(!empty($_POST['reg_email']) && !preg_match('/^[a-zA-Z0-9-_.]+@[a-zA-Z0-9-_.]+\.[a-zA-Z]{2,4}$/', $_POST['reg_email']))
$errors[] = 'The e-mail address is not valid';
if(!empty($_POST['reg_captcha']) && md5($_POST['reg_captcha']) != $_SESSION['captcha'])
$errors[] = 'The captcha is entered incorrectly!';
if(empty($_POST['reg_rules']))
$errors[] = 'You have to have read the rules and accept!';
if(isset($_POST['reg_submit'])) {
if(count($errors) > 0) {
echo '<div class="fail">';
foreach($errors as $error) {
echo $error.'<br/>';
}
echo '</div>';
} else {
odbc_exec($mssql, 'INSERT INTO [dbo].[ACCOUNT_TBL] (account, password, isuse, member, id_no1, id_no2, realname, reload, OldPassword, TempPassword, cash , votepoints) VALUES (N\''.mssql_escape_string($_POST['reg_username']).'\', N\''.mssql_escape_string(md5($_CONFIG['pwdsalt'].$_POST['reg_password'])).'\', N\'T\', N\'A\', NULL, 0, N\'P\', NULL, 0, NULL, 0, 0)');
odbc_exec($mssql, 'INSERT INTO [dbo].[ACCOUNT_TBL_DETAIL] (account, gamecode, tester, m_chLoginAuthority, regdate, BlockTime, EndTime, WebTime, isuse, secession, email) VALUES (N\''.mssql_escape_string($_POST['reg_username']).'\', N\'A000\', N\'2\', N\'F\', \''.mssql_escape_string(date('Ymd H:i:s')).'\', N\'20010101\', N\'20990101\', N\'20050101\', N\'O\', NULL, N\''.mssql_escape_string($_POST['reg_email']).'\')');
echo '<div class="success">Your account has been created!</div>';
}
}
?>
<form method="post">
<table>
<tr>
<td>Username:</td>
<td><input class="Input_Text" type="text" name="reg_username" maxlength="10" /></td>
</tr>
<tr>
<td>Password:</td>
<td><input class="Input_Text" type="password" name="reg_password" maxlength="11" /></td>
</tr>
<tr>
<td>Repeat Password:</td>
<td><input class="Input_Text" type="password" name="reg_confirmpw" /></td>
</tr>
<tr>
<td>E-Mail Address:</td>
<td><input class="Input_Text" type="text" name="reg_email" /></td>
</tr>
<tr>
<td></td>
<td style="text-align: center;"><img src="./inc/captcha.php" /></td>
</tr>
<tr>
<td>Captcha:</td>
<td><input class="Input_Text" type="text" name="reg_captcha" /></td>
</tr>
</table>
<p style="text-align: center"><input type="checkbox" name="reg_rules" value="1" /> <b> I have read the <a href="rules.php">Rules</a> and agree by completing my Registration.</p>
<table>
<tr>
<td style="width: 115px;"></td>
<td style="text-align: center;"><input class="Input_Button" type="submit" name="reg_submit" value="Register" /></td>
</tr>
</table>
</form>
<?php include('inc/footer.php'); ?>