Esempio n. 1
0
    }
    // Check the product description
    if (!isset($productDescription)) {
        $errorMessage[] = "Please type in a product description.";
    }
    // Check for the price and if it's a number
    if (!isset($productPrice) || !is_numeric($productPrice)) {
        $errorMessage[] = "Please type in a product price and make sure to use only digits.";
    }
    // if the message array is empty, go and process the form
    if (!$errorMessage) {
        /**
        * Insert the captured details if the previous checkks did not return any errors
        */
        // Check which is the biggest ID in the users table and set the AUTO_INCREMENT accordingly to prevent empty user rows when deleting existing users
        $biggestID = vQuery("ALTER TABLE products AUTO_INCREMENT = 1");
        // insert the details in the database
        $sql = "INSERT INTO products (productName, productDescription, productPrice, productQuantity) VALUES ('{$productName}', '{$productDescription}', '{$productPrice}', '{$productQuantity}')";
        $insert = query($sql);
        if (!empty($insert)) {
            // generate a failure message
            $errorMessage[] = "There was a problem adding the product {$productName} into the system. Please try again";
        } else {
            // generate a success message
            $errorMessage[] = "You have successfully added the product named: {$productName}.";
            header("Refresh: 5 url=manageProducts.php");
        }
    }
}
?>
        $errorMessage[] = "Please enter your date of birth in the following format: mm/dd/yyyy.";
    }
    // check for duplicate email registered to the system
    $checkDuplicateEmail = query("SELECT * FROM customers WHERE email = '{$email}'");
    // if the array returns a result
    if ($checkDuplicateEmail) {
        // display a message
        $errorMessage[] = "The email address: {$email}, you have tryed to register with is already in our system. Please choose another one and try again.";
    }
    // if the message array is empty, go and process the form
    if (!$errorMessage) {
        /**
        * Insert the captured details if the previous checks did not return any errors
        */
        // Check which is the biggest ID in the users table and set the AUTO_INCREMENT accordingly to prevent empty user rows when deleting existing users
        $biggestID = vQuery("ALTER TABLE custoemrs AUTO_INCREMENT = 1");
        // insert the details in the database
        $sql = "INSERT INTO users (firstName, lastName, dob, gender, email, phone, password) VALUES ('{$firstName}', '{$lastName}', '{$DOB}', '{$gender}', '{$email}', '{$phone}', '{$password}')";
        $insert = iQuery($sql);
        if (!empty($insert)) {
            // generate a failure message
            $errorMessage[] = "There was a problem adding the user {$email} into the system. Please try again";
        } else {
            // generate a success message
            $errorMessage[] = "Thank you for registering at BoxGifts.";
        }
    }
}
?>
<!doctype html>
<html>