PHP Developers Network

A community of PHP developers offering assistance, advice, discussion, and friendship.
It is currently Sun Sep 20, 2020 1:13 pm

All times are UTC - 5 hours

Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: Confusing directory PHP
PostPosted: Wed Jan 05, 2011 8:47 pm 
Forum Newbie

Joined: Wed Jan 05, 2011 8:35 pm
Posts: 1
This is code for my HTML page which is supposed to gather data from a visitor for a directory and send it to a PHP file for storage and manipulation:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
<html xmlns="">
<title>Directory Listing</title>
<h3>Please enter personal information</h3>
<form action="Directory2b.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>
<h3>please enter dash in telephone number for our records.</h3>
<input type="reset" value="Clear Form" />&nbsp;
&nbsp;<input type="submit" name="submit" value="send form" />
This entry form does work as far as collecting the data and sending it to the PHP file but i need to reset it after each set of data is entered and that is my issue. The data entered here is stored as a string into an array of strings which I need to be able to manipulate and sort but no matter what I try I can only get one set of data to be entered and so the array only has one string in it. :dubious: The array always has whatever was the last set of data entered and nothing else and I need advice how to reset the HTML page to receive multiple data sets so that I can fill up my array. :banghead:
Anyway here is the PHP file code:
Syntax: [ Download ] [ Hide ]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
<html xmlns="">
error_reporting(E_ALL & ~E_NOTICE);
$words[] = wordCheck($lname, "lastname");
$words[] = wordCheck($fname, "firstname");
$words[] = wordCheck($addr, "address");
$words[] = wordCheck($cty, "city");
$words[] = wordCheck($stat, "state");
$words[] = wordCheck($zip, "zipcode");
$words[] = wordCheck($acode, "areacode");
$words[] = wordCheck($phone, "telephone");
global $errorCount;
function DisplayError($fieldName, $errorMsg)
echo "Error for \"$fieldName\": $errorMsg<br \>\n";
function wordCheck($data, $fieldName)
if (empty($data))
DisplayError($fieldName, "Please enter $fieldName");
$retval = "";
return $data;
if ($errorCount>0)
echo "Please re-enter data.<br />\n";
$filename = "file.txt";
$fp = fopen($filename, "w+");
$output =array("$lname , $fname ,  $addr ,  $cty ,  $stat , $zip , $acode - $phone");
foreach($output as $directory){

  echo "$directory";
and as I stated this does also work in collecting the data from the HTML file and placing it into an array as a string but I cannot get any more strings from the HTML page into this file because I do not know how to reset it properly. :cry: That is what I really need is for someone to tell me how to collect more data from different users and insert all of it into a single array from processing. I will await your reply!! :bow:

PostPosted: Wed Jan 05, 2011 8:58 pm 
Forum Commoner

Joined: Sat Oct 16, 2010 4:30 pm
Posts: 91
Location: Lithuania, Vilnius
Do you want to collect your data as in this example : ?
$zip = array("zip1", "zip2", "zip3") ???
$email = array('email1", "email2", "email3") ???

There are 2 possibilities to do this:

1.If you don't understand how to work with database, you can just put all your zip's in 1 file, all your emails in 2 file and so on. These files will be like temporary storages, then you can retrieve all your distinct values in distinct arrays and work with them.

.2 but if you can do things with database, it will be even easier to retrieve all emails, zips, ......

Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 5 hours

Who is online

Users browsing this forum: No registered users and 9 guests

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group