вот взял готовый код но непашит(
_config.php
- Код: Выделить всё • Развернуть
$realm["host"] = "localhost";
$realm["user"] = "mangos";
$realm["pass"] = "mangos";
$realm["db"] = "mangos-logon";
register.php
- Код: Выделить всё • Развернуть
<?php
<tr class=listlabel>
<td>
<b>Создание аккаунта</b>
</td>
<td align=right>
<i> </i>
</td>
<tr>
<?php
include("./_config.php");
/*********************************/
/* Модуль регистрации */
/*********************************/
// Проверка e-mail
function check_email($email = '')
{
global $cfg_mail_need;
$pattern = "^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$";
if (!$cfg_mail_need)
return 1;
if (strlen($email) < 6)
return 0;
if (!eregi($pattern, $email))
return 0;
return 1;
}
// //
if (empty($_POST['username']) and empty($_POST['passw']) and empty($_POST['email']))
{
$cont='<form name=RegisterForm method=post action=register.php>
<TABLE>
<TR>
<TD align=left width=190>
<LABEL>Учетная запись:</LABEL>
<INPUT id=username style="WIDTH: 175px" tabIndex=1 maxLength=16 size=18 name=username>
</TD>
</TR>
<TR>
<TD align=left width=190>
<LABEL>Пароль:</LABEL>
<INPUT id=passw style="WIDTH: 175px" tabIndex=2 type=password maxLength=12 size=18 name=passw>
</TD>
</TR>
<TR>
<TD align=left width=190>
<LABEL>E-mail:</LABEL>
<INPUT id=email style="WIDTH: 175px" tabIndex=4 maxLength=50 size=18 name=email>
</TD>
</TR>
<TR>
<TD align=left width=190>
<LABEL>Включить поддержку аддона:</LABEL>
<select size="1" name="tbc">
<option selected value="1">Burning Crusade</option>
<option value="0">Classic WoW</option>
</select>
</TD>
</TR>
<TR>
<TD colspan=2 align=left>
<INPUT class=button type="submit" tabIndex=5
value="Создать аккаунт">
</TD>
</TR>
</table>
</form>';
}
elseif (empty($_POST['username']) or empty($_POST['passw']) or ($cfg_mail_need && empty($_POST['email'])) )
{
$cont = '<TABLE>
<TR>
<TD align=Center>
<SMALL class=error>Вы не ввели один из параметров.<br><br><a href="" onClick="history.go(-1)">Вернуться назад.</a>
</SMALL>
</TD>
</TR>
</TABLE>';
}
else
{
$username = htmlspecialchars(trim($_POST['username']));
$passw = trim($_POST['passw']);
$sha_pass_hash = sha1(strtoupper("$username:$passw"));
$email = htmlspecialchars(trim($_POST['email']));
$tbc = trim($_POST['tbc']);
$ip = $_SERVER['REMOTE_ADDR'];
if (!check_email($email)) { // bad format!
$cont='<TABLE><TR><TD align=Center><SMALL class=error>
Неправильный e-mail.<br><br><a href="" onClick="history.go(-1)">Вернуться назад</a></SMALL></TD></TR></TABLE>';
}
else if (strlen($username) < 4 || strlen($passw) < 4) { // too short!!!
$cont='<TABLE><TR><TD align=Center><SMALL class=error>
Логин или пароль слишком короткие<br><br><a href="" onClick="history.go(-1)">Вернуться назад</a></SMALL></TD></TR></TABLE>';
}
else {
$realm_db = mysql_connect($realm["host"],$realm["user"],$realm["pass"]);
if (empty($email))
$cont = '<TABLE><TR><TD align=Center><SMALL class=error>
Не указан email. Пожалуйста укажите ваш email<br><br><a href="" onClick="history.go(-1)">Вернуться назад</a></SMALL></TD></TR></TABLE>';
$query = mysql_query("INSERT INTO `realmd`.`account` (`username`,`sha_pass_hash`,`email`,`tbc`) VALUES ('".$username."','".$sha_pass_hash."','".$email."','".$tbc."')", $realm_db);
if($query)
{
$cont='<TABLE><TR><TD align=Center><SMALL>
Аккаунт для <br><strong>'.$username.'</strong><br> создан<br>
<br><a href="" onClick="history.go(-1)">Вернуться назад</a>
</SMALL></TD></TR></TABLE>';
}
else
{
$cont='<TABLE><TR><TD align=Center><SMALL class=error>
Аккаунт<br><strong>'.$username.'</strong><br>не создан
<br><br><a href="" onClick="history.go(-1)">Вернуться назад</a></SMALL></TD></TR></TABLE>';
}
}
mysql_close($realm_db);
}
print "$cont";
?>
</td>
</tr>
</table>
?>