Jump to content

empty fields


dhmyers82

Recommended Posts

<h2>Scholarship Form</h2>
<form name="scholarship" action="process_Scholarship.php" method="post">
	<p>First Name: <input type="text" name="fname" /></p>
	<p>Last Name: <input type="text" name="lname" /></p>
	<p><input type="reset" value="Clear Form" />  <input type="submit" value="Send Form" /></p>
</form>
<?php
error_reporting(E_ALL);
ini_set('display_errors', 'on');

$firstName = validateInput($_POST['fname'], "First Name");
$lastName = validateInput($_POST['lname'], "Last Name");
if ($errorCount<0)
	echo "Please use the \"Back\" button to re-enter data.<br />\n";
else
	echo "<p>Thank you for filling out the scholarship form, ".$firstName." ".$lastName.".";

function displayRequired($fieldName) {
	echo "The field \"$fieldName\" is required.<br />\n";
}
	
function validateInput($data, $fieldName) {
	global $errorCount;
	if (empty($date)) {
		displayRequired($fieldName);
		++$errorCount;
		$retval = "";
	} else {//Only clean up the input if it isn't empty
		$retval = trim($data);
		$retval = stripslashes($retval);
	}
	return($retval);
}
$errorCount = 0;

?>

it always reads the form as empty, and spits out the error message. why will it not read the names I enter?

Link to comment
https://forums.phpfreaks.com/topic/294654-empty-fields/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.