function form_validation($uname, $pwd, $email, $dob, $sex, $state, $city, $news)
{
    $error_message = "";
    $error_message = validate_username($uname, $error_message);
    $error_message = validate_password($pwd, $error_message);
    $error_message = validate_email($email, $error_message);
    $error_message = validate_dob($dob, $error_message);
    $error_message = validate_sex($sex, $error_message);
    $error_message = validate_state($state, $error_message);
    $error_message = validate_city($city, $error_message);
    $error_message = validate_newsletter($news, $error_message);
    if ($error_message) {
        echo "<br>I am sorry, but you haven't filled the form correctly. Please check the following.<br><br>" . $error_message;
        // echo "I am now redirecting you to the previous page. Please fill it correctly this time.";
        // header ( "Location: ../Client/signup.html" );
        return 0;
    } else {
        return 1;
    }
}
Example #2
0
function main_validation($email, $password1, $password2, $fname, $lname, $sex)
{
    if (verify_email($email) == true and verify_password($password1, $password2, $lname) == true and validate_sex($sex) == true) {
        //$username = validate_username($username);
        $password = sha1($password1);
        $cxn = $GLOBALS['cxn'];
        $last_ip = $_SERVER['REMOTE_ADDR'];
        $priv = "user";
        $query = "INSERT INTO user_list (email, password, first_name, last_name, date_added, last_login, last_ip, privlege_level, sex) \n\t\t\t\tVALUES(?, ?, ?, ?, NOW(), NOW(), ?, ?, ?)";
        $stm2 = $cxn->prepare($query);
        if ($GLOBALS['$debug'] == true) {
            echo $email . "..." . $password . "..." . $fname . "..." . $lname . "..." . $last_ip . "..." . $priv . "..." . $sex;
        }
        $stm2->bind_param("sssssss", $email, $password, $fname, $lname, $last_ip, $priv, $sex);
        $stm2->execute();
        $stm2->close();
        // pull user ID for session data
        $uid = get_user_id($email);
        //// set session infos
        $_SESSION['signed_in'] = true;
        $_SESSION['fname'] = $fname;
        $_SESSION['email'] = $email;
        $_SESSION['user_id'] = $uid;
        $_SESSION['privleges'] = "user";
        //$_SESSION['city'] = $city;
        //$_SESSION['state'] = $state;
        return true;
    } else {
        $_SESSION['signed_in'] = false;
        return false;
    }
}
Example #3
0
$conn = db_connect();
$fail = NULL;
if (isset($_POST['username']) || isset($_POST['fullname']) || isset($_POST['password_1']) || isset($_POST['sex'])) {
    $table = 'users_sfu';
    $username = $_POST['username'];
    $fullname = $_POST['fullname'];
    $password_1 = $_POST['password_1'];
    $password_2 = $_POST['password_2'];
    $sex = $_POST['sex'];
    $interest_1 = $_POST['interest-1'];
    $interest_2 = $_POST['interest-2'];
    $interest_3 = $_POST['interest-3'];
    $fail = validate_username($username);
    $fail .= validate_password($password_1, $password_2);
    $fail .= validate_fullname($fullname);
    $fail .= validate_sex($sex);
    // No errors
    if ($fail === "") {
        $data = array("username" => sanitize_MySQL($conn, $username), "fullname" => sanitize_MySQL($conn, $fullname), "password" => sanitize_MySQL($conn, crypt($password_1, 'moneys')), "sex" => sanitize_MySQL($conn, $sex), "interest-1" => sanitize_MySQL($conn, $interest_1), "interest-2" => sanitize_MySQL($conn, $interest_2), "interest-3" => sanitize_MySQL($conn, $interest_3));
        /*
        // Mail isn't working
        $to = $username . '@sfu.ca';
        $subject = 'hi';
        $body = 'i am body';
        $headers = 'From: admin@jumpstart.ca';
        
        if (mail($to, $subject, $body, $headers)) {
          print 'mail sent';
        }
          
        else {