I am very new to PHP and keep getting a parse error that says unexpected end of file. I have checked every curly brace, quotation mark, semi colon, and more and can't seem to find out what is causing it. Any help would be greatly appreciated!
<?php
if(isset($_POST['calculate'])) {
$errors =array();
$fname = $_POST["firstname"];
$fname = trim($fname);
$fname = strtolower($fname);
$fname = ucfirst($fname);
$lname = $_POST["lastname"];
$lname = trim($lname);
$lname = strtolower($lname);
$lname = ucfirst($lname);
$hworked = $_POST["hoursworked"];
$hwage = $_POST["hourlywage"];
//Validating empty elements
if(empty($fname)) {
$errors['fnameempty'] = "*";
}
if(empty($lname)) {
$errors['lnameempty'] = "*";
}
if(empty($hworked)) {
$errors['hoursempty'] = "*";
}
if(empty($hwage)) {
$errors['wageempty'] = "*";
}
//Ensuring Fname and lname are at least two characters
validateName($fname, 'fnamelength');
validateName($lname, 'lnamelength');
validateLongName($lname, 'lnamelong');
//Ensuring Hourrly wage is numeric and greater than 10
validateNumeric($hwage);
validateWage($hwage);
//Ensuring hours worked is numeric and does not exceed 60
validateNumeric($hworked);
validateHours ($hworked);
if(count($errors) == 0) {
header("Location: success.php");
exit();
} else {
$fname="";
$lname="";
$hwage="";
$hworked="";
{
}
//Functions
function validateName($name, $short) {
global $errors;
if (!empty($name)) {
if(strlen($name) < 2){
$errors[$short] = "must be at least 2 characters";
}
}
}
function validateLongName($name, $long) {
global $errors;
if (!empty($name)) {
if (strlen($name) > 25) {
$errors[$long] = 'name cannot exceed 25 characters';
}
}
}
function validateNumeric ($validate) {
global $errors;
if (!is_numeric($validate)) {
$errors ="only numeric values are allowed";
}
}
function validateWage ($wageval) {
global $errors;
if ($wageval < 10) {
$errors = "wage must be 10 or above";
}
}
function validateHours ($hourval) {
global $errors;
if($hourval > 60) {
$errors = "hours must not exceed 60";
}
}
?>
It looks like you're new here. If you want to get involved, click one of these buttons!
Comments
Second line above
//Functions
, opening curly brace should not be there.