Example #1
0
function getYoungsters($people)
{
    if (!doValidation($people)) {
        sendMessage(doValidation($people));
        return false;
    }
    $i = 0;
    // Get year from date
    foreach ($people as $person) {
        preg_match("/[0-9]+/", $person['dob'], $matches);
        $age = abs(date('Y') - $matches[0]);
        if ($age < 21) {
            $folks[$i]['age'] = $age;
            $folks[$i]['name'] = $person['name'];
            $i++;
        }
    }
    return !empty($folks) ? $folks : null;
}
<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>0303 HTML Forms - php</title>
	<link rel="stylesheet" href="css/KingLib_8.css">
</head>
<body>
	<div id="logo-div">
		<a href="assignment_8.php"><img src="images/KingLibLogo.jpg" alt=""></a>
	</div>

	<?php 
include "assignment_8_common_functions.php";
doValidation();
/*
if (!doValidation()) {
	addPatron();
}
*/
?>

	<p>For Admin Use Only: <a href="assignment_8_view_patrons.php">View Patrons</a></p>

	<?php 
getServer();
?>
</body>
</html>
Example #3
0
<?php

$project = $_POST['project'];
$errors = doValidation($project);
function doValidation($project = "test")
{
    require_once 'third_party/PHPExcel/PHPExcel.php';
    $errors = array();
    $projectPath = __DIR__ . "/upload/" . $project . "/";
    // Ensure the project path exists
    if (!file_exists($projectPath)) {
        $errors[] = "Invalid project path given";
        return $errors;
    }
    $excelFile = "";
    if ($projectDirHandle = opendir($projectPath)) {
        while (false !== ($entry = readdir($projectDirHandle))) {
            if (pathinfo($entry, PATHINFO_EXTENSION) == "xlsx") {
                $excelFile = $entry;
            }
        }
        closedir($projectDirHandle);
    }
    if (empty($excelFile)) {
        $errors[] = "No Media Grid file found";
        return $errors;
    }
    $objPHPExcel = PHPExcel_IOFactory::load($projectPath . $excelFile);
    // TODO Check if we can safely assume only one worksheet per file
    // Iterate through all the sheets in the excel workbook and store as an array
    foreach ($objPHPExcel->getWorksheetIterator() as $worksheet) {
Example #4
0
    } else {
        if (is_numeric($email)) {
            echo "False";
        } else {
            if (is_float($email)) {
                echo "False";
            } else {
                if (is_bool($email)) {
                    echo "False";
                } else {
                    if (strlen($email) < 5) {
                        echo "False";
                    } else {
                        if (strpos($email, "@") == false) {
                            echo "False";
                        } else {
                            if (strpos($email, ".") == false) {
                                echo "False";
                            } else {
                                echo "True";
                            }
                        }
                    }
                }
            }
        }
    }
}
//Pass your email value into the function to validate.
doValidation('*****@*****.**');