Esempio n. 1
0
     $messages['#signup-phone'] = '!!!_Invalid phone number._!!!';
 } else {
     $query = "SELECT phone\n            FROM nf_users\n            WHERE phone = '" . $data['phone'] . "'\n            OR username = '******'phone'] . "'\n            OR email = '" . $data['phone'] . "'\n        ";
     if ($res = @mysqli_query($MV, $query)) {
         if (@mysqli_fetch_assoc($res)) {
             $messages['#signup-phone'] = '!!!_This phone is already registered._!!!';
         }
     } else {
         $messages['error'] = '!!!_DB Error_!!!';
         $response = json_encode($messages);
         return;
     }
 }
 if ($data['username'] == "") {
     $messages['#signup-username'] = '******';
 } elseif (is_valid_phone($data['username'])) {
     $messages['#signup-username'] = '******';
 } elseif (is_valid_email($data['username'])) {
     $messages['#signup-username'] = '******';
 } else {
     $query = "SELECT username\n            FROM nf_users\n            WHERE username = '******'username'] . "'\n            OR email = '" . $data['username'] . "'\n            OR phone = '" . $data['username'] . "'\n        ";
     if ($res = @mysqli_query($MV, $query)) {
         if (@mysqli_fetch_assoc($res)) {
             $messages['#signup-username'] = '******';
         }
     } else {
         $messages['error'] = '!!!_DB Error_!!!';
         $response = json_encode($messages);
         return;
     }
 }
Esempio n. 2
0
     $last_name = string_corrector($_POST["lastName"]);
     if (!$last_name) {
         echo "نام خانوادگی نمی تواند خالی باشد";
         echo "<br>";
         exit;
     } elseif ($result = update_user_last_name($user_id, $last_name) === true) {
         echo "نام خانوادگی کاربر با موفقیت تغییر کرد";
         echo "<br>";
     } else {
         echo "مشکلی پیش آمده است.لطفا بعدا تلاش کنید";
         echo "<br>";
         exit;
     }
 }
 if (isset($_POST["phone"])) {
     $phone = is_valid_phone($_POST["phone"]);
     if (!$phone) {
         echo "شماره ی وارد شده نامعتبر است.لطفا شماره ی تلفن ثابت را با کدشهر وارد کنید";
         echo "<br>";
     } elseif (update_user_phone_number($user_id, $phone) === true) {
         echo "شماره ی تلفن با موفقیت تغییر کرد";
         echo "<br>";
     } else {
         echo "مشکلی پیش آمده است.لطفا بعدا تلاش کنید";
         echo "<br>";
         exit;
     }
 }
 if (isset($_POST["userName"])) {
     $username = english_string_corrector($_POST["userName"]);
     if (!$username) {
Esempio n. 3
0
 }
 // Check that principal amount is numeric and greater than zero
 if ($label == $labels['principal']) {
     if (is_valid($_POST[$label]) && is_num_above_zero($_POST[$label]) == false) {
         echo "<li>" . $labels['principal'] . $rules['numeric_above_zero'] . "</li>";
     }
 }
 // Check that interest rate is numeric and not negative
 if ($label == $labels['interest']) {
     if (is_valid($_POST[$label]) && is_num_not_negative($_POST[$label]) == false) {
         echo "<li>" . $labels['interest'] . $rules['numeric_not_negative'] . "</li>";
     }
 }
 // Check for valid phone number
 if ($label == $labels['phone']) {
     if (is_valid($_POST[$label]) && is_valid_phone($_POST[$label]) == false) {
         echo "<li>" . $labels['phone'] . $rules['valid_phone'] . "</li>";
     }
 }
 // Check for valid email address
 if ($label == $labels['email']) {
     if (is_valid($_POST[$label]) && is_valid_email($_POST[$label]) == false) {
         echo "<li>" . $labels['email'] . $rules['valid_email'] . "</li>";
     }
 }
 // Check for empty checkbox array
 if ($label == $labels['contactTime']) {
     if ($_POST[$label] == []) {
         echo "<li>" . 'Since ' . $_POST[$labels['contactMethod']] . $rules['valid_contact_time'] . "</li>";
     }
 }
Esempio n. 4
0
<?php

// Put all post data into their own variables
extract($_POST);
// (1) Verify that all info was provided
// (2) Verify that a valid phone number was provided
if ($first_name != '' && $last_name != '' && $email != '' && $phone != '' && is_valid_phone($phone)) {
    // Open the data file for appending
    $file = fopen('../data/contacts.txt', 'a+');
    // Create a timestamp
    $timestamp = time();
    // Apend entered onformation to the file
    fwrite($file, "{$first_name},{$last_name},{$email},{$phone},{$timestamp}\n");
    // Close the data file
    fclose($file);
    // Redirect to the list of contacts
    header('Location:../?p=contacts');
}
/**
 * Validated that a phone number is numeric and has 10 digits
 * @param String $phone
 * @return True of the number is valid, false otherwise
 */
function is_valid_phone($phone)
{
    if (strlen($phone) == 10 && is_numeric($phone)) {
        return true;
    } else {
        return false;
    }
}