Jump to content
n0TTT_

[Resolvido] Código de registo correcto ?

Recommended Posts

n0TTT_
<?php
if(isset($_POST['username'], $_POST['password'], $_POST['passverif'], $_POST['email'], $_POST['avatar']) and $_POST['username']!='')
{
if(get_magic_quotes_gpc())
{
$_POST['username'] = stripslashes($_POST['username']);
$_POST['password'] = stripslashes($_POST['password']);
$_POST['passverif'] = stripslashes($_POST['passverif']);
$_POST['email'] = stripslashes($_POST['email']);
$_POST['avatar'] = stripslashes($_POST['avatar']);
}
if($_POST['password']==$_POST['passverif'])
{
if(strlen($_POST['password'])>=6)
{
if(preg_match('#^(([a-z0-9!\#$%&\\\'*+/=?^_`{|}~-]+\.?)*[a-z0-9!\#$%&\\\'*+/=?^_`{|}~-]+)@(([a-z0-9-_]+\.?)*[a-z0-9-_]+)\.[a-z]{2,}$#i',$_POST['email']))
{
$username = mysql_real_escape_string($_POST['username']);
$password = mysql_real_escape_string(sha1($_POST['password']));
$email = mysql_real_escape_string($_POST['email']);
$avatar = mysql_real_escape_string($_POST['avatar']);
$dn = mysql_num_rows(mysql_query('select id from users where username="'.$username.'"'));
if($dn==0)
{
$dn2 = mysql_num_rows(mysql_query('select id from users'));
$id = $dn2+1;
if(mysql_query('insert into users(id, username, password, email, slot1, slot2, slot3, money, kills, deaths, score, level, admin, signup_date) values ('.$id.', "'.$username.'", "'.$password.'", "'.$email.'", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "'.time().'")'))
{
$form = false;
?>
<div class="message_s">You have successfully been signed up. You can now log in.<br />
<a href="login.php">Log in</a></div>
<?php
}
else
{
$form = true;
$message = 'Ocorreu um erro ao te registares!';
}
}
else
{
$form = true;
$message = 'ERRO<br /> O username que inseriste já existe!';
}
}
else
{
$form = true;
$message = 'ERRO<br />O email que iseriste não é válido!';
}
}
else
{
$form = true;
$message = 'ERRO <br />A password deve ter no minimo 6 digitos.';
}
}
else
{
$form = true;
$message = 'ERRO<br />As passwords não coincidem!';
}
}
else
{
$form = true;
}
if($form)
{
if(isset($message))
{
echo '<div id="signup"><div class="message_f">'.$message.'</div>';
}
?>
<div class="form">
<form action="signup.php" method="post">
	Please fill this form to sign up:<br />
	<div class="center">
		<label for="username">Username</label><input type="text" name="username" value="<?php if(isset($_POST['username'])){echo htmlentities($_POST['username'], ENT_QUOTES, 'UTF-8');} ?>" /><br />
		<label for="password">Password<span class="small">(6 characters min.)</span></label><input type="password" name="password" /><br />
		<label for="passverif">Password<span class="small">(verification)</span></label><input type="password" name="passverif" /><br />
		<label for="email">Email</label><input type="text" name="email" value="<?php if(isset($_POST['email'])){echo htmlentities($_POST['email'], ENT_QUOTES, 'UTF-8');} ?>" /><br />
		<input type="submit" value="Sign Up" />
</div>
</form>
</div>
</div>
<?php
}
?>

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.