Hi all, I have a little problem, I’m trying to make my registration page object orientated. I do my pre-registration checks at the top of the page because I do a header redirect if there are no errors to the next stage.
However, if there are any errors then I want to display a message further down the page but it doesn’t want to work…any ideas…?
<?php
include('includes/login.class.php');
$login = new login;
//Controller for customer resgister...
if(isset($_POST['login'])):
$login->preRegisterChecks($_POST['email'], $_POST['pass'], $_POST['word']);
endif;
?>
<td class="content">
<div><img src="/images/assets/account_center.jpg" width="739" height="96" alt="Your Shopping Cart"/></div>
<div class="categoryNav" style="margin-bottom: 9px;">
<div class="categoryPos"><span style="font-size: 12px; font-weight: bold;">
Account Center
</span></div>
</div>
<form action="<?php echo $_SERVER['REQUEST_URI'] ?>" method="post">
<div class="registerSide">
<div class="goingOn">New Customer</div>
<?php
echo $login->errors($error);
?>
Email:<br/>
<input type="text" class="loginField" name="email" value="<?php echo $_POST['email'] ?>" /><br/>
New Password:<br/>
<input type="password" class="loginField" name="pass"/><br/>
Re-enter Password<br/>
<input type="password" class="loginField" name="word"/>
<input type="submit" name="login" value="Login"/>
</div>
<div class="registerSide" style="margin-left: 10px;">
<div class="goingOn">Existing Customer Sign In</div>
Email:<input type="text" name="eimail" value="" /><br/>
Password: <input type="password" name="paiss"/>
<input type="password" name="woird"/>
<input type="submit" name="loigin" value="Login"/>
</div>
</form>
</td>
The class:
<?php
class login {
function preRegisterChecks($email, $password, $passwordRetype){
//If passwords do not match...
if($password!==$passwordRetype):
$error = "<div class=\\"loginError\\">";
$error .= "Passwords do not match!";
$error .= "</div>";
return $this->errors($error);
//If there is no email address...
elseif(empty($email)):
$error = "<div class=\\"loginError\\">";
$error .= "You haven't entered an email address!";
$error .= "</div>";
return $error;
//If the email address isn't valid...
elseif(!filter_var($email, FILTER_VALIDATE_EMAIL)):
$error = "<div class=\\"loginError\\">";
$error .= "You haven't entered a VALID email address!";
$error .= "</div>";
return $error;
//If there password is less than five characters...
elseif(strlen($password) < 4):
$error = "<div class=\\"loginError\\">";
$error .= "You password needs to be at least five characters!";
$error .= "</div>";
return $error;
else:
$_SESSION['NEW_EMAIL'] = $email;
$_SESSION['NEW_PASS'] = md5($password);
header('Location: /register/');
endif;
}
function errors($err){
return $err;
}
}
?>
Any help or advice is appreciated