only the first phone listing is in the table cells? Also how do I make the phone number come out as xxx-xxx-xxxx?
I included the 2 other php associated files below it...
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Phone Entries</title>
</head>
<body bgcolor="#FFFF99">
<h1 align="center">Phonebook</h1>
<table align='center'><tr><td width=150px align=center bgcolor=#A4B3EC><h2>Name</h2></td>
<td width=100px align=center bgcolor=#A4B3EC><h2>Phone</h1></td></tr>
<?php
$File = "directory.txt";
if (!file_exists($File)) {
echo "<div align='center'><p>There are no entries.</p>";
echo "<p>Click <a href='javascript: history.go(-1)'>here</a> to add an entry</p></div>";
}
else $Listing = file($File); {
for ($i=0; $i<count($Listing); $i++) {
$ListingArray = explode(",", $Listing[$i]);
echo "<tr bgcolor=pink><td width=150px align=center>$ListingArray[1], $ListingArray[0]</td>";
echo "<td width=50px align=center>$ListingArray[6]-$ListingArray[7]</p></td></tr></table>";
}
}
echo "<p align='center'>Click <a href='javascript: history.go(-1)'>here</a> to return to the form.</p>";
?>
</body>
</html>
ADDING ENTRIES file
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Telephone Entries</title>
</head>
<body bgcolor="#FFFF99">
<?php
$FirstName = $_GET['fname'];
$LastName = $_GET['lname'];
$Address = $_GET['address'];
$City = $_GET['city'];
$State = $_GET['state'];
$ZipCode = $_GET['zip'];
$AreaCode = $_GET['area'];
$Phone = $_GET['phone'];
if (empty($FirstName) || empty($LastName) || empty($Address) || empty($City) || empty($State) || empty($ZipCode) || empty($AreaCode) || empty($Phone)) {
echo "<p align='center'>You must complete each field.</p>";
$Listing = NULL;
}
else if (!is_numeric($ZipCode) || !is_numeric($AreaCode) || !is_numeric($Phone)) {
echo "<p align='center'>The Zip Code, Area Code, and Phone Numbers fields can only contain numeric characters.</p>";
$Listing = NULL;
}
else {
$Listing = $FirstName . ",";
$Listing .= $LastName . ",";
$Listing .= $Address . ",";
$Listing .= $City . ",";
$Listing .= $State . ",";
$Listing .= $ZipCode . ",";
$Listing .= $AreaCode . ",";
$Listing .= $Phone . "\r\n";
}
$DirectoryFile = fopen("directory.txt","a");
if (flock($DirectoryFile, LOCK_EX))
if (fwrite($DirectoryFile, $Listing)) {
echo "<div align='center'><h1>Listing saved!!!</h1>";
echo "$FirstName $LastName<br />$Address<br />$City, $State $ZipCode<br />($AreaCode)$Phone<br />";
echo "Click <a href='javascript: history.go(-1)'>here</a> to return to the form.</div>";
}
else {
echo "<p align='center'>Listing information could not be saved.</p>";
echo "<p align='center'>Click <a href='javascript: history.go(-1)'>here</a> to return to the form.</p>";
}
else {
echo "<p align='center'>Click <a href='javascript: history.go(-1)'>here</a> to return to the form.</p>";
}
fclose($DirectoryFile); // Close the file
?>
</body>
</html>
WEBPAGE FILE
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Phonebook</title>
</head>
<body bgcolor="#FFFF99">
<h3 align="center">Phonebook</h3>
<table align="center">
<form action="addlisting.php" method="get" enctype="application/x-www-form-urlencoded">
<tr>
<th colspan="2" align="center">Add an entry</th>
</tr>
<tr>
<td >First Name: </td>
<td><input type="text" name="fname" /></td>
</tr>
<tr>
<td>Last Name: </td>
<td><input type="text
I included the 2 other php associated files below it...
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Phone Entries</title>
</head>
<body bgcolor="#FFFF99">
<h1 align="center">Phonebook</h1>
<table align='center'><tr><td width=150px align=center bgcolor=#A4B3EC><h2>Name</h2></td>
<td width=100px align=center bgcolor=#A4B3EC><h2>Phone</h1></td></tr>
<?php
$File = "directory.txt";
if (!file_exists($File)) {
echo "<div align='center'><p>There are no entries.</p>";
echo "<p>Click <a href='javascript: history.go(-1)'>here</a> to add an entry</p></div>";
}
else $Listing = file($File); {
for ($i=0; $i<count($Listing); $i++) {
$ListingArray = explode(",", $Listing[$i]);
echo "<tr bgcolor=pink><td width=150px align=center>$ListingArray[1], $ListingArray[0]</td>";
echo "<td width=50px align=center>$ListingArray[6]-$ListingArray[7]</p></td></tr></table>";
}
}
echo "<p align='center'>Click <a href='javascript: history.go(-1)'>here</a> to return to the form.</p>";
?>
</body>
</html>
ADDING ENTRIES file
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Telephone Entries</title>
</head>
<body bgcolor="#FFFF99">
<?php
$FirstName = $_GET['fname'];
$LastName = $_GET['lname'];
$Address = $_GET['address'];
$City = $_GET['city'];
$State = $_GET['state'];
$ZipCode = $_GET['zip'];
$AreaCode = $_GET['area'];
$Phone = $_GET['phone'];
if (empty($FirstName) || empty($LastName) || empty($Address) || empty($City) || empty($State) || empty($ZipCode) || empty($AreaCode) || empty($Phone)) {
echo "<p align='center'>You must complete each field.</p>";
$Listing = NULL;
}
else if (!is_numeric($ZipCode) || !is_numeric($AreaCode) || !is_numeric($Phone)) {
echo "<p align='center'>The Zip Code, Area Code, and Phone Numbers fields can only contain numeric characters.</p>";
$Listing = NULL;
}
else {
$Listing = $FirstName . ",";
$Listing .= $LastName . ",";
$Listing .= $Address . ",";
$Listing .= $City . ",";
$Listing .= $State . ",";
$Listing .= $ZipCode . ",";
$Listing .= $AreaCode . ",";
$Listing .= $Phone . "\r\n";
}
$DirectoryFile = fopen("directory.txt","a");
if (flock($DirectoryFile, LOCK_EX))
if (fwrite($DirectoryFile, $Listing)) {
echo "<div align='center'><h1>Listing saved!!!</h1>";
echo "$FirstName $LastName<br />$Address<br />$City, $State $ZipCode<br />($AreaCode)$Phone<br />";
echo "Click <a href='javascript: history.go(-1)'>here</a> to return to the form.</div>";
}
else {
echo "<p align='center'>Listing information could not be saved.</p>";
echo "<p align='center'>Click <a href='javascript: history.go(-1)'>here</a> to return to the form.</p>";
}
else {
echo "<p align='center'>Click <a href='javascript: history.go(-1)'>here</a> to return to the form.</p>";
}
fclose($DirectoryFile); // Close the file
?>
</body>
</html>
WEBPAGE FILE
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Phonebook</title>
</head>
<body bgcolor="#FFFF99">
<h3 align="center">Phonebook</h3>
<table align="center">
<form action="addlisting.php" method="get" enctype="application/x-www-form-urlencoded">
<tr>
<th colspan="2" align="center">Add an entry</th>
</tr>
<tr>
<td >First Name: </td>
<td><input type="text" name="fname" /></td>
</tr>
<tr>
<td>Last Name: </td>
<td><input type="text