예제 #1
0
 public static function account_validate($username, $firstname, $lastname, $email)
 {
     $user = new Access();
     if (empty($username)) {
         validate::$er_message = '<i style="color: red;">Username field cannot be left empty</i><br/>';
         return false;
     }
     if (empty($email)) {
         validate::$er_message .= '<i style="color: red;">Email field cannot be left empty</i><br/>';
         return false;
     }
     if (empty($firstname)) {
         return true;
     }
     if (strlen($firstname) > 10 || strlen($firstname) < 2) {
         validate::$er_message = '<i style="color: red;">First name must be greater the 2 characters and less the 10 characters long! </i><br/>';
         return false;
     }
     if (is_numeric($firstname)) {
         validate::$er_message = '<i style="color: red;">First name must be letters only!</i><br/>';
         return false;
     }
     if (empty($lastname)) {
         return true;
     }
     if (strlen($lastname) > 10 || strlen($lastname) < 2) {
         validate::$er_message = '<i style="color: red;">Last name must be greater the 2 characters and less the 10 characters long! </i><br/>';
         return false;
     }
     if (is_numeric($lastname)) {
         validate::$er_message = '<i style="color: red;">Last name must be letters only!</i><br/>';
         return false;
     }
     if (User::ifUserExist($email) == true && $email == $user->get_email($_SESSION['uid'])) {
         return true;
     } elseif (User::ifUserExist($email) == true && $email !== $user->get_email($_SESSION['uid'])) {
         validate::$er_message = '<i style="color: red;">Someone else is already using that email address!</i><br/>';
         return false;
     }
     if (Validate::is_valid_email($email) == false) {
         validate::$er_message .= '<i style="color: red;">Please enter a valid email address!</i><br/>';
         return false;
     } else {
         return true;
     }
 }
예제 #2
0
    <div class="login" style="width: 400px;">
        <form id="contactform" name="login" method="post" action="">
            <fieldset id="contactform">
                <?php 
echo Validate::$er_message;
?>

                <?php 
$user = new Access();
echo '<div class="one_full_c">';
echo '<label for="subject">My Username:<span></span></label>';
echo '<input type="text" name="username" id="subject" value="' . $user->get_user_name($_SESSION['uid']) . '" class="required requiredField subject" />';
echo '</div>';
echo '<div class="one_full_c">';
echo '<label for="subject">My Email:<span></span></label>';
echo '<input type="text" name="email" id="subject" value="' . $user->get_email($_SESSION['uid']) . '" class="required requiredField subject" />';
echo '</div>';
//echo '<div class="one_full_c">';
//echo '<label for="subject">My Password:<span></span></label>';
//echo '<input type="password" name="password" id="subject" value="" class="required requiredField subject" />';
//echo '</div>';
echo '<div class="one_full_c">';
echo '<label for="subject">My first Name:<span></span></label>';
echo '<input type="text" name="firstname" id="subject" value="' . $user->get_f_name($_SESSION['uid']) . '" class="required requiredField subject" />';
echo '</div>';
echo '<div class="one_full_c">';
echo '<label for="subject">My Last Name:<span></span></label>';
echo '<input type="text" name="lastname" id="subject" value="' . $user->get_l_name($_SESSION['uid']) . '" class="required requiredField subject" />';
echo '</div>';
echo '<div class="one_full_c">';
echo '<input type="hidden" name="id" id="submitted" value="' . $_SESSION['uid'] . '" />';