writing to a text file
Posted: Wed Jun 26, 2013 8:45 am
I'm trying to save email addresses to a text file - (not having a great deal of success)
****Form for getting the email addresses**********
<form action="submit.php" method="post">
<label for="email">Your E-Mail Address : </label><br><br>
<input type="text" name="email">
<input type="submit" value="Submit" />
</form>
***********Submit.PHP for entering data into text file***************
<?php
$fw = fopen("textfile.txt", 'w');
fwrite ($fw, $_POST['email']);
fclose($fw);
?>
**********emailadds.PHP for displaying text file data********************
<?php
$file = textfile.txt";
$f = fopen($file, "r");
while ( $line = fgets($f, 1000))
print $line;
?>
Problem 1 - Emails are not being entered into text file
(if I enter them manually).
Problem 2 they do not display
question - Why, I thought the code was ok (I'm not a PHP coder consequently I'm struggling)
Can anyone help please.
****Form for getting the email addresses**********
<form action="submit.php" method="post">
<label for="email">Your E-Mail Address : </label><br><br>
<input type="text" name="email">
<input type="submit" value="Submit" />
</form>
***********Submit.PHP for entering data into text file***************
<?php
$fw = fopen("textfile.txt", 'w');
fwrite ($fw, $_POST['email']);
fclose($fw);
?>
**********emailadds.PHP for displaying text file data********************
<?php
$file = textfile.txt";
$f = fopen($file, "r");
while ( $line = fgets($f, 1000))
print $line;
?>
Problem 1 - Emails are not being entered into text file
(if I enter them manually).
Problem 2 they do not display
question - Why, I thought the code was ok (I'm not a PHP coder consequently I'm struggling)
Can anyone help please.