need help with this contact form


Posted on 16th Feb 2014 07:03 pm by admin

I made this form and I need it to read the data and write the data to a table and its not working can someone please help me and show me what I have wrong so I can fix it

heres the html form I left off the doc type so it dont take up that much room

<form>
<h1>Telephone Directory</h1>


<table align='Left'>
<tr>
<td>LastName</td>
<td><input name='LastName' /></td>
</tr>
<tr>
<td>FirstName</td>
<td><input name='FirstName' /></td>
</tr>
<tr>
<td>StreetAddress</td>
<td><input name='StreetAddress' /></td>
</tr>
<tr>
<td>City</td>
<td><input name='City' /></td>
</tr>
<tr>
<td>State</td>
<td><input name='State' /></td>
</tr>
<tr>
<td>Zip</td>
<td><input name='Zip' /></td>
</tr>
<tr>
<td>AreaCode</td>
<td><input name='AreaCode' /></td>
</tr>
<tr>
<td>PhoneNumber</td>
<td><input name='PhoneNumber' /></td>
</tr>
<tr>
<td></td>
<td><input type="submit" value="Submit" /></td>
<td><a href="Telephonewrite.php">ReadFile</a></td>
</tr>
</table>
</form>
</body>
</html>

php.file to read


<body>
<h1>Telephone Directory</h1>
<?php
$fileHandle=fopen("read.txt","r");
readfile("read.txt");
$record=fgets($fileHandle);
echo("<table><tr><td>FirstName</td><td>LastName</td><td>StreetAddress</td><td>City</td><td>State</td>
<td>Zip</td><td>AreaCode</td><td>PhoneNumber</td></tr>");
while(!feof($fileHandle))
{
$myArray=explode("|",$record);
echo "<tr><td>$myArray[0]</td><td>$myArray[1]</td></tr>";
$record =fgets($fileHandle);
$record =fgets($LastName);
$record =fgets($FirstName);
$record =fgets($StreetAddress);
$record =fgets($City);
$record =fgets($State);
$record =fgets($Zip);
$record =fgets($AreaCode);
$record =fgets($PhoneNumber);
}
echo "</table>"
?>
</body>
</html>


the php file to write

<body>
<h1>Telephone Directory</h1>
<hr />
<?php
if(isset($_GET['PhoneNumber']) && isset($_GET['LastName'])) {
$LastName = $_GET['LastName'];
$FirstName = $_GET['FirstName'];
$StreetAdress = $_GET['StreetAddress'];
$City = $_GET['City'];
$State = $_GET['State'];
$Zip = $_GET['Zip'];
$AreaCode = $_GET['AreaCode'];
$PhoneNumber = $_GET['PhoneNumber'];
$record=$LastName. "|";
$record=$FirstName. "|";
$record .="rn";
$fileHandle = fopen("read.txt","a");
readfile("read.txt");
if(fwrite($read, $record)>0)
echo "<p>your entry was successfully added to the file</p>";
else
echo "<p>No data was written, please return to the form</p>";
fclose($fileHandle);
}
?>
<a href="Telephone.html">Form</a>
</body>
</html>

No comments posted yet

Your Answer:

Login to answer
292 Like 44 Dislike
Previous forums Next forums
Other forums

All possible combinations of String in PL/SQL
Hi All,

Could you please explain the logic of getting all possible combinations of String

show random images
hey guys

can someone please suggest a way in which the following code can be edited so it onl

Problem related to Creation of PDF File?
Hi All,
I am facing a problem related to creation pdf file. when I am creating a pdf file of do

Pre-Fill out a PHP form...??
This is for work actually (geek squad). We have to fill out this online php form at work over and ov

I would like "for" to wait 5 sec
I would like my 'for' loop to wait 5 sec before second iteration.


for ($i=0; $i<10

How to calculate days from variable date?
This will be easy for one of you gurus. I want to fetch the date from a variable date, for example:<

check if value exists
I have googled this for a while and I am getting lots of different results. Is there a standard meth

Calender Not Opening
The following code is not loading the javascript calender in another window. It's not doing anything

Drawing Images in classes
I'm quite new to Object Oriented PHP. What I'm trying to do is draw some images but also have other

script is pulling more then they have....
I have this script for my game where they can change there race. This will cost them 2,500 points. H

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash