Esempio n. 1
0
<?php

$data = $_POST;
$result = array("color" => "#2EE619", "text" => "Correct!", "status" => 0);
if ($data["name"] == "username_sign") {
    $result = usernameValidation($data["value"], $result);
} elseif (strpos($data["name"], "password") !== false) {
    $result = passwordValidation($data["value"][0], $data["value"][1], $data["name"], $result);
} elseif ($data["name"] == "email") {
    $result = emailValidation($data["value"], $result);
} elseif ($data["name"] == "first_name") {
    $result = firstnameValidation($data["value"], $result);
} elseif ($data["name"] == "second_name") {
    $result = secondnameValidation($data["value"], $result);
}
if ($result["text"] != "Correct!") {
    $result["color"] = "#F71111";
    $result["status"] = 1;
}
echo json_encode($result);
function usernameValidation($data, $result)
{
    require_once "db.class.php";
    if (strlen($data) == 0) {
        $result["text"] = 'Its Empty!';
    } elseif (strlen($data) < 4) {
        $result["text"] = 'Too short!';
    } elseif (strlen($data) > 20) {
        $result["text"] = 'Pls add more no problem (yes there is a problem)';
    } elseif ($data == "vaseto") {
        $result["text"] = 'The God is the only one';
if ($review_mark == "") {
    $errors[] = "Поле 'Ваша оценка' не заполнено!";
}
function emailValidation($review_email)
{
    if ($review_email) {
        if (preg_match("/[0-9a-z_\\.\\-]+@[0-9a-z_\\.\\-]+\\.[a-z]{2,4}/i", $review_email)) {
            return true;
        } else {
            return false;
        }
    } else {
        return false;
    }
}
if (emailValidation($review_email) == false) {
    $errors[] = "Введите корректный E-mail";
}
// Если в переменной $email действительно электронный адрес,
// если форма без ошибок
if (empty($errors)) {
    $answer = add_reviews_user($pdo, $review_fio, $review_email, $review_text, $review_mark, $review_date);
    $msg_box = "<span style='color: red;'>" . $answer . "</span>";
} else {
    // если были ошибки, то выводим их
    $msg_box = "";
    foreach ($errors as $one_error) {
        $msg_box .= "<span style='color: red;'>{$one_error}</span><br/>";
    }
}
echo json_encode(array('result' => $msg_box));
Esempio n. 3
0
<?php

include 'include/core.php';
$message = "";
if ($_SERVER['REQUEST_METHOD'] == "GET") {
    if (isset($_GET['message'])) {
        $message = $_GET['message'];
    }
}
if ($_SERVER['REQUEST_METHOD'] == "POST") {
    $emailid = trim($_POST['email']);
    $password = trim($_POST['password']);
    if (!empty($emailid) && !empty($password)) {
        //echo "</br> Not empty Fields";
        //----------------------------------
        if (emailValidation($emailid)) {
            //echo "</br> Valid email";
            //------------------------------
            if (isMailRegistered($emailid)) {
                //echo "</br> email Registered";
                //--------------------------
                if (isUserAuthenticated($emailid, $password)) {
                    //check if email and password is correct
                    /*Now we should Redirect to Home Page */
                    redirect("index.php");
                } else {
                    $message = "Wrong Password...</br>Please Try Again..!";
                }
            } else {
                $message = "Dear " . $emailid . "</br>Your Account Does Not Exist. Please Register";
            }
Esempio n. 4
0
    $mail->Username = '******';
    //Password
    $mail->Password = '******';
    //Set FROM field
    $mail->setFrom('*****@*****.**', 'Jerry Krusinski');
    //Set TO field
    $mail->addAddress($email);
    //Set the SUBJECT
    $mail->Subject = $subject;
    //Set Message
    $mail->msgHTML($message);
    //Send Message, Check for errors
    return $mail->send();
}
$email = $_POST['email'];
$result = emailValidation($email);
if (!$result) {
    //Write the subject
    $subject = 'View battleship( ); on your desktop!';
    $html = "<h3 style='font-family: monospace;'>battleShip(); - A Game By Jerry Krusinski</h3>";
    $html .= "<br/><hr/>";
    $html .= "<p>Follow this <a href='//jkrusinski.com/battleShip'>link</a> to check out battleShip!";
    $html .= " Written in Javascript with jQuery, battleShip is a simple, fun, and addicting game built to ";
    $html .= "practice front end technologies. To view the source code, make sure to travel over to ";
    $html .= "its <a href='//github.com/jkrusinski/battleShip'>GitHub Repository</a> as well!</p>";
    $html .= "<hr/><p><a href='//jkrusinski.com'>My site</a> is always under construction with performance ";
    $html .= "enhancements and new projects added, so make sure to check back often!</p>";
    $html .= "<br/><p>Thank you for checking out my portfolio!</p>";
    $sent = sendMail($email, $subject, $html);
    if (!$sent) {
        $result = 'Error in sendMail function';