Пример #1
0
    die('Connection error: (' . $connect->connect_errno . '): ' . $connect->connect_error);
}
?>

<body>

<h1>Validation of Organization Addresses</h1>

<?php 
$sql = "SELECT * FROM organization";
$result = $connect->query($sql) or die($connect->error);
echo '<table border="1"><tr><th>Organization ID</th><th>Organization Name</th><th>Address</th><th>Phone</th></tr>';
while ($result2 = $result->fetch_array(MYSQLI_ASSOC)) {
    if (isValidOrgName($result2['org_name']) && isValidAddress($result2['org_street']) && isValidString($result2['org_state']) && isValidZIPCode($result2['org_zip']) && isValidPhone($result2['org_phone'])) {
    } else {
        echo '<tr><td>' . $result2['org_id'] . '</td><td>' . $result2['org_name'] . '<br>' . formatValid(isValidOrgName($result2['org_name'])) . '</td><td>' . $result2['org_street'] . ", " . $result2['org_city'] . ", " . $result2['org_state'] . " " . $result2['org_zip'] . '<br> Street:' . formatValid(isValidAddress($result2['org_street'])) . '<br>City: ' . formatValid(isValidString($result2['org_state'])) . '<br>ZIP:' . formatValid(isValidZIPCode($result2['org_zip'])) . '</td><td>' . $result2['org_phone'] . '<br>' . formatValid(isValidPhone($result2['org_phone'])) . '</td>';
        echo '</tr>';
    }
}
/* while ($result2 = $result->fetch_array(MYSQLI_ASSOC)) {
	
	echo '<tr><td>' . $result2['org_id'] . '</td><td>' . $result2['org_name'] . '<br>' . formatValid(isValidOrgName($result2['org_name'])) . '</td><td>' . $result2['org_street'] . ", " . $result2['org_city'] . ", " . $result2['org_state'] . " " . $result2['org_zip'] . '<br> Street:' . formatValid(isValidAddress($result2['org_street'])) . '<br>City: ' . formatValid(isValidString($result2['org_state'])) . '<br>ZIP:' . formatValid(isValidZIPCode($result2['org_zip'])) . '</td><td>' . $result2['org_phone'] . '<br>' . formatValid(isValidPhone($result2['org_phone'])) . '</td>';
	
	echo '</tr>';
	
} */
echo '</table>';
?>


</body>
Пример #2
0
 if ($_POST['orgstate'] != "CA") {
     echo '<strong><font color="#ff0000">Sorry, we cannot do food drives outside of California</font></strong>';
     $errcount++;
 } else {
     echo stripslashes(htmlentities($_POST['orgstate']));
 }
 echo ' <strong>ZIP:</strong> ';
 function isValidZIPCode($zipcode)
 {
     return preg_match("/^[0-9]{5}(-[0-9]{4})?\$/i", trim($zipcode)) > 0 ? true : false;
 }
 if (isValidZIPCode($_POST['orgzip']) == false) {
     $errcount++;
     echo '<strong><font color="#ff0000">Invalid ZIP code!</font></strong>';
 }
 if (isValidZIPCode($_POST['orgzip']) == true) {
     echo stripslashes(htmlentities($_POST['orgzip']));
 }
 function isValidPhone($phone)
 {
     $result = preg_replace("/\\D/", "", $phone);
     if (substr($result, 0, 1) == 1) {
         $result = substr($result, 1);
     }
     if (strlen($result) < 10) {
         return false;
     } else {
         return true;
     }
 }
 echo '<p><strong>Phone:</strong> ';