Zeus
Active Member
- Jun 30, 2012
- 150
- 30
- Thread starter
- #21
That indenting... I hope that's just because you pasted it into this post ;P
No it's not actually like that, it's just DevBest which fucks it up, I don't know why. But anyway i've re-coded all of the register
PHP:
<?php
require_once "global.php";
define('regSelected', true);
if($users->LoggedIn()) {
header('Location: dashboard');
}
if(!$config->regEnabled) {
header('Location: /?regEnabled');
}
$tpl->assign('regError', null);
if(isset($_POST['submit'])) {
$email = $db->real_escape_string($_POST['email']);
$pass = $db->real_escape_string($_POST['password']);
$rpass = $db->real_escape_string($_POST['rpassword']);
$fname = $db->real_escape_string($_POST['fname']);
$lname = $db->real_escape_string($_POST['lname']);
if ($result = $db->query("SELECT * FROM `users` WHERE `email` = '".$email."'")) {
if($result->num_rows != '0') {
$tpl->assign('regError', '<div class="alert alert-error">Account email taken, please login</div>');
}
} if(strlen($lname) == '0' || strlen($fname) == '0') {
$tpl->assign('regError', '<div class="alert alert-error">Please fill in all fields</div>');
} else if(strlen($pass) < '6') {
$tpl->assign('regError', '<div class="alert alert-error">Password legnth needs to be at least 6 characters</div>');
} else if($pass !== $rpass) {
$tpl->assign('regError', '<div class="alert alert-error">Both passwords needs to be the same</div>');
} else if(!$users->checkEmail($email)) {
$tpl->assign('regError', '<div class="alert alert-error">Your email is not valid</div>');
} else {
$users->addUser($email, $hash->encrypt($pass), $fname, $lname);
$_SESSION['email'] = $email;
header ("Location: dashboard");
}
}
$tpl->assign('pageTitle', 'Register!');
$tpl->draw('header');
$tpl->draw('navi');
$tpl->draw('register');
?>