I am trying to finish a project and have hit a snag and since I got helpful advice in this forum before I thought I give it another try. I am trying to make an html page that collects personal data and sends it to a php file that should store the data and show it on the screen.Unfortunately although the html file is calling the php file there is no data being sent between the two files. This is my code from the two files:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Words for Jumble</title>
</head>
<body>
<h3>Please enter personal information</h3>
<form action="Directory.php" method="post">
<p>Lastname: <input type="text" name="lastname"></p>
<p>Firstname: <input type="text" name="firstname"></p>
<p>Address: <input type="text" name="address"</p>
<p>City: <input type="text" name="city"</p>
<p>State: <input type="text" name="state"></p>
<p>Zipcode: <input type="text" name="zipcode"></p>
<p>Areacode: <input type="text" name="areacode"></p>
<p>Telephone: <input type="text" name="telephone"></p>
<input type="reset" value="Clear Form" />
<input type="submit" name="submit" value="send form" />
</form>
</body>
</html>
That is the html file which does open a web page with field labeled to enter information but it does not seem to be sending anything:icon_sad: to this php file:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<title>Directory</title>
<body>
<b>Account Information:</b>
<?php
error_reporting(E_ALL & ~E_NOTICE);
function DisplayError($fieldName, $errorMsg) {
echo "Error for \"$fieldName\": $errorMsg<br \>\n";
++$errorCount; }
function wordCheck($data, $fieldName) {
global $errorCount;
if (empty($data)) {
displayError($fieldName, "Please enter $fieldName");
$retval = "";}
else {
if (preg_match("/^[a-z]+$/i", $retval)==0){
displayError($fieldName, "Words must be letters only");
}
return($retval);
}
$words[] = wordCheck($_POST["lastname"], "lastname");
$words[] = wordCheck($_POST["forstname"], "firstname");
$words[] = wordCheck($_POST["address"], "address");
$words[] = wordCheck($_POST["city"], "city");
$words[] = wordCheck($_POST["state"], "state");
$words[] = wordCheck($_POST["zipcode"], "zipcode");
$words[] = wordCheck($_POST["areacode"], "areacode");
$words[] = wordCheck($_POST["telephone"], "telephone");
if ($errorCount>0)
echo "Please re-enter data.<br />\n";
else {
$wordnum = 0;
foreach ($words as $Word)
echo "Word ", ++$wordnum.": $Word<br />\n";
} }
?>
</body>
</html>
This does not even give error messages if you enter nothing in the html fields so I don't think the two files are sharing entered data at all!!:icon_cry:
Any assistance would be appreciated greatly as I am fairly new to server side scripting and do not have the familiarity with php to see what mistake or mistakes I have made here. I will await any helpful advice and thanks!!:icon_smile: