예제 #1
0
function authenticatePaymentMethodPOST()
{
    //cardfirst, middle, lastname
    $error = array();
    isset($_POST['cardfirstname']) ? $name[0] = htmlspecialchars(strip_tags($_POST['cardfirstname'])) : ($name[0] = "");
    isset($_POST['cardmiddlename']) ? $name[1] = htmlspecialchars(strip_tags($_POST['cardmiddlename'])) : ($name[1] = "");
    isset($_POST['cardlastname']) ? $name[2] = htmlspecialchars(strip_tags($_POST['cardlastname'])) : ($name[2] = "");
    for ($i = 0; $i < count($name); $i++) {
        if ($name[$i] == "") {
            $error[] = "Name field cannot be left blank!";
        }
    }
    //four1, four2, four3, four4
    isset($_POST['four1']) ? $cardnum[0] = htmlspecialchars(strip_tags($_POST['four1'])) : ($cardnum[0] = "");
    isset($_POST['four2']) ? $cardnum[1] = htmlspecialchars(strip_tags($_POST['four2'])) : ($cardnum[1] = "");
    isset($_POST['four3']) ? $cardnum[2] = htmlspecialchars(strip_tags($_POST['four3'])) : ($cardnum[2] = "");
    isset($_POST['four4']) ? $cardnum[3] = htmlspecialchars(strip_tags($_POST['four4'])) : ($cardnum[3] = "");
    for ($j = 0; $j < count($cardnum); $j++) {
        if ($cardnum[$j] == "") {
            $error[] = "Please enter four digits in card number field : " . $j;
        }
        if (!is_numeric($cardnum[$j])) {
            $error[] = "Only integer values are accepted in card number field : " . $j;
        }
    }
    //expiration, cardtype
    isset($_POST['expiration']) ? $exp = htmlspecialchars(strip_tags($_POST['expiration'])) : ($exp = "");
    if ($exp == "") {
        $error[] = "Expiration field must not be left empty!";
    }
    isset($_POST['cardtype']) ? $type = htmlspecialchars(strip_tags($_POST['cardtype'])) : ($type = "");
    if ($type == "") {
        $error[] = "Card type field must not be left empty!";
    }
    //street, city, state, zip, apt
    isset($_POST['street']) ? $street = htmlspecialchars(strip_tags($_POST['street'])) : ($street = "");
    if ($street == "") {
        $error[] = "Street field must not be empty!";
    }
    isset($_POST['city']) ? $city = htmlspecialchars(strip_tags($_POST['city'])) : ($city = "");
    if ($city == "") {
        $error[] = "City field must not be empty!";
    }
    isset($_POST['zip']) ? $zip = htmlspecialchars(strip_tags($_POST['zip'])) : ($zip = "");
    if ($zip == "") {
        $error[] = "Zip field must not be empty!";
    }
    if (!is_numeric($zip)) {
        $error[] = "Zip must be an integer!";
    }
    isset($_POST['apt']) ? $apt = htmlspecialchars(strip_tags($_POST['apt'])) : ($apt = "");
    if ($apt == "") {
        $error[] = "Apartment field must not be left blank!";
    }
    if (count($error) > 0) {
        displayPaymentMethod();
        for ($d = 0; $d < count($error); $d++) {
            echo "<label class='formerror'>" . $error[$d] . "</label><br>";
        }
    } else {
        displayOrderConfirmation();
    }
}
예제 #2
0
	height=50px; 
}
</style> 
</head> 
<body> 
<?php 
include 'automate/header.php';
@($q = $_GET['q']);
echo "<p>Q : " . $q . " </p>";
switch ($q) {
    case 'authenticate':
        authenticatePaymentMethodPOST();
        break;
    case 'cart':
        displayCart();
        break;
    case 'authenticateCart':
        authenticateCartPOST();
        break;
    case 'payment':
        displayPaymentMethod();
        break;
    default:
        displayPaymentMethod();
        break;
}
include 'automate/footer.php';
?>
 
</body> 
</html>