| mend3 |
17-07-2009 01:59 AM |
Script - Criar conta
1 Anexo(s)
Bom, um usuário fez um pedido dele, então vou postar pra todos vocês:
Script de criação de conta com:
o Login;
o Senha;
o Repetir Senha;
o E-mail;
o Pergunta secreta;
o Resposta secreta;
Crie um arquivo em PHP (criarconta.php por exemplo), copie os códigos, cole e salve.
Basta configurar o acesso ao banco de dados.
Código PHP:
<head> <title>Criar conta</title> </head> <?php $L2JBS_config["mysql_host"]="localhost"; // MySQL IP $L2JBS_config["mysql_port"]=3306; // MySQP port $L2JBS_config["mysql_db"]="l2jdb"; // interlude or your lineage 2 server database name $L2JBS_config["mysql_login"]="root"; // MySQL Login name $L2JBS_config["mysql_password"]="root"; // MySQL Password
error_reporting(0); ?> <?php $L2JBS_config["javascript_sort_method"]="bubble"; $link = mysql_connect($L2JBS_config['mysql_host'].":".$L2JBS_config['mysql_port'], $L2JBS_config['mysql_login'], $L2JBS_config['mysql_password']); if (!$link) die("Couldn't connect to MySQL"); @mysql_select_db($L2JBS_config['mysql_db'], $link) or die ('Error '.mysql_errno().': '.mysql_error());
?>
Código:
<center>
<body>
<font size="4" color="red" face="Verdana"> Para segurança de sua conta, preencha todos os campos do formulário.</font>
<form method="post" action="?ir=reg" onsubmit="return checkform(this)">
<table>
<tr>
<td><b><font face="Arial" color="gold" size="3">Login</font></b></td>
<td><font face="Arial" size="1"><b>
<input type="text" name="account" maxlength="15" size="20" /></b></font></td>
</tr>
<tr>
<td><b><font face="Arial" color="gold" size="3">E-mail</font></b></td>
<td><font face="Arial" size="1"><b>
<input type="text" name="email" maxlength="150" size="20" /></b></font></td>
</tr>
<tr>
<td><b><font face="Arial" color="gold" size="3">Senha</font></b></td>
<td><font face="Arial" size="1"><b>
<input type="password" name="password" maxlength="15" size="20" /></b></font>
</tr>
<tr>
<td><b><font face="Arial" color="gold" size="3">Repetir Senha</font></b></td>
<td><font face="Arial" size="1"><b>
<input type="password" name="password2" maxlength="15" size="20" /></b></font></td>
</tr>
<tr>
<td><b><font face="Arial" color="gold" size="3">Pergunta secreta</font></b></td>
<td><font face="Arial" size="1"><b>
<input type="text" name="question" maxlength="15" size="20" /></b></font></td>
</tr>
<tr>
<td><b><font face="Arial" color="gold" size="3">Resposta secreta</font></b></td>
<td><font face="Arial" size="1"><b>
<input type="password" name="answer" maxlength="15" size="20" /></b></font></td>
</tr><br>
</table>
<br><br>
<input type="image" src="http://www.secretwarez.net/images/confirmar.png" name="submit" value="Criar conta"/>
<a href="/paginas/home.php"><img src="http://www.secretwarez.net/images/cancelar.png" alt="Cancelar" title="Cancelar" /></a>
</form>
</center>
<script type="text/javascript">//<![CDATA[
function isAlphaNumeric(value)
{
if (value.match(/^[a-zA-Z0-9]+$/))
return true;
else
return false;
}
function checkform(f)
{
if (f.account.value=="")
{
alert("Preencha todos os campos!");
return false;
}
if (!isAlphaNumeric(f.account.value))
{
alert("Preencha todos os campos!");
return false;
}
if (f.password.value=="")
{
alert("Sem Senha ");
return false;
}
if (!isAlphaNumeric(f.password.value))
{
alert("444444");
return false;
}
if (f.password2.value=="")
{
alert("Você não repetiu a senha");
return false;
}
if (f.password.value!=f.password2.value)
{
alert("Senhas não são iguais ");
return false;
}
if (f.question.value=="")
{
alert("Digite uma pergunta secreta!");
return false;
}
if (f.answer.value=="")
{
alert("Digite uma resposta secreta!");
return false;
}
return true;
}
//]]></script>[/html][php]
<?php
if(ereg("^([a-zA-Z0-9_-])*$", $_POST['account']) && ereg("^([a-zA-Z0-9_-])*$", $_POST['password']) && ereg("^([a-zA-Z0-9_-])*$", $_POST['password2']) && ereg ("^([a-zA-Z0-9_-])*$", $_POST['question']) && ereg ("^([a-zA-Z0-9_-])*$", $_POST['answer']))
{
if ($page="index.php" && $_POST['account'] && strlen($_POST['account'])<16 && strlen($_POST['account'])>3 && $_POST['password'] && $_POST['password2'] && $_POST['password']==$_POST['password2'])
{
$check=mysql_query("select * from accounts where login='".$_POST['account']."'");
$check1=mysql_num_rows($check);
if($check1>0)
{
echo "<p clss='error'><center /><b><font color=\"red\" />Falha no Registro, Conta já Existe .</b></p>";
}
$check=mysql_query("select * from accounts where email='".$_POST['email']."'");
$check1=mysql_num_rows($check);
if($check1>0)
{
echo "<p clss='error'><center /><b><font color=\"red\" />Falha no Registro, E-mail já Existe .</b></p>";
}
else
{
mysql_query("INSERT INTO accounts (login, password, email, question, answer) VALUES ('".$_POST['account']."', '".base64_encode(pack('H*', sha1($_POST['password'])))."', '".$_POST['email']."', '".$_POST['question']."', '".$_POST['answer']."')", $link);
mysql_close($link);
print '<p class="error"><center><b><font color="gold" />Registro Completo<br>Conta <font color="green">'.$_POST['account'].'</font> criada com sucesso. </b></p></center>';
}
}
else
{
print '<p class="error"><b> </b></p>'.mysql_error();
}
}
else
{
echo "As limitações não foram testadas para a segurança. Se você for confiável que tido a informação correta, consultar por favor à administração. ";
}
?>
Gente, esqueci a SQL, quem tiver posta ae. Quem não tiver, peço que espere um pouco :D
[Somente Usuários Registrados Podem Visualizar os Links Desta PáginaClique aqui para se Registrar]
|