Hello all
this code for register to Battle of the Immortals
PHP Code:
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<?php
include "MSSql.php";
$db = "PassportBOI";
$host = "IP\\SQLEXPRESS";
$user = "sa";
$password = "password";
$cMSSql = new MSSql($db,$host,$user,$password);
if($_POST)
{
$username = $_POST["username"];
$pwd = $_POST["pwd"];
$repwd = $_POST["repwd"];
$creatime = date("Y-m-d H:i:s");
if($username > 3)
{
echo"<script>alert('Need Username over 3 char.');history.back();</script>";
exit() ;
}
if((isset($pwd)) and ($pwd!=$repwd))
{
echo"<script>alert('Password wrong.');history.back();</script>";
exit() ;
}
if(!eregi("^([a-zA-Z0-9])*$",$username))
{
echo"<script>alert('Username have been a-z, A-Z, 0-9 only.');history.back();</script>";
exit() ;
}
//declare the SQL statement that will query the database
$rows = $cMSSql->quick_num("SELECT name FROM account WHERE name='$username'");
$idCount = $cMSSql->quick_num("SELECT name FROM account");
if($rows>0)
{
echo "<script>alert('Username not ready.');history.back();</script>";
exit();
}
else
{
$pwdx = $username.$pwd;
//$pwdx = $pwd.$pwd;
$Salt = md5($pwdx);
$password = "0x".$Salt;
$idCount = $idCount+1;
$cMSSql->execute("
Insert Into account
(id,creatime,name,passwd,usertype)
Values
('$idCount','$creatime','$username',$password,'1')
");
echo "<script>alert('Register $username done.');history.back();</script>";
exit();
}
}
?>
<form action="" method="post" name ="checkForm" id="checkForm" onSubmit="return check()">
<table align="center" border="0" cellpadding="0" cellspacing="0" width="300" style="font-size:12px;color: #754831;">
<tr>
<td align="right" width="130" height="25">Username : </td>
<td align="left" width="170" height="25"><input type="text" name="username" size="15" maxlength="12" style="width: 150px; height:20px;font-size:12px;color: #754831;"></td></tr>
<tr>
<td align="right" width="130" height="25">Password : </td>
<td align="left" width="170" height="25"><input type="password" name="pwd" size="15" maxlength="18" style="width: 150px; height:20px;font-size:12px;color: #754831;"></td></tr>
<tr>
<td align="right" width="130" height="25">RePassword : </td>
<td align="left" width="170" height="25"><input type="password" name="repwd" size="15" maxlength="18" style="width: 150px; height:20px;font-size:12px;color: #754831;"></td></tr>
<tr>
<td align="right" width="130" height="30"><input type="submit" name="Submit" value="ยืนยัน" onclick="return check_register_form()"> </td>
<td align="left" width="170" height="30"> <input type="reset" name="Reset" value="ล้างค่า"></td>
</tr>
</table>
</form>