dhmyers82 Posted February 16, 2015 Share Posted February 16, 2015 <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? Quote Link to comment https://forums.phpfreaks.com/topic/294654-empty-fields/ Share on other sites More sharing options...
Solution raphael75 Posted February 16, 2015 Solution Share Posted February 16, 2015 Should this line: if (empty($date)) { be if (empty($data)) { ? Quote Link to comment https://forums.phpfreaks.com/topic/294654-empty-fields/#findComment-1505843 Share on other sites More sharing options...
dhmyers82 Posted February 16, 2015 Author Share Posted February 16, 2015 That will do it. Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/294654-empty-fields/#findComment-1505844 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.