Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Saving form data to a text file

Status
Not open for further replies.

xrac

Programmer
Feb 19, 2003
2
0
0
US
Hey all, Im trying to create an unsubscribe page using PHP I tryed all the tutorials I can find, and all the pre made scripts, but Im not geting this, I cant seem to pass the form data to the PHP page then to the file.

my output looks like this on the php page
Were sorry to see you leave rememail

and the text remove.rtf shows
rememail
no matter what I put in the input field

heres the HTML page
<html>
<head>
<title>Unsubscribe from our newsletter</title>
</head>
<body>
<form action=&quot;remove.php&quot; method=&quot;post&quot;>
<center><table>
<tr>
<td><b>Enter the email address to remove.</b></td><br>
<br>
</tr>
<tr>
<td><input type=&quot;text&quot; name=&quot;rememail&quot; size=&quot;30&quot;></td>
</tr>
</table>
<input type=&quot;submit&quot; value=&quot;Unsubscribe&quot;>
</center>
</form>
</body>
</html>

and the PHP file
<html>
<?php
$filename = 'remove.rtf';
$address = 'rememail'; <--- I believe my issue is here

if (is_writable($filename)) {
if (!$fp = fopen($filename, 'a')) {
print &quot;There was an error during saving please go back and resubmit&quot;;
exit;
}

if (!fwrite($fp, &quot;$address \n&quot;)) {
print &quot;There was an error during saving please go back and resubmit&quot;;
exit;
}

print &quot;Were sorry to see you leave $address&quot;;

fclose($fp);

} else {
print &quot;There was an error during saving please go back and resubmit&quot;;
}
?>
</html>
 
probably u need this:

$address = $_POST['rememail'] ; <--- I believe my issue is here

spookie


--------------------------------------------------------------------------
I never set a goal because u never know whats going to happen tommorow.
 
ryancomps solution will only work if register globals is set to on, which is NOT the recommended or default setting in recent versions of PHP. Leaving it off is a good idea for several reasons.

-Rob

(I know this is usually yours sleipnir, I do good with it?)
 
Well the $_POST['rememail'];
didnt work late last night when I was trying to do this,, but alas it works today( damned if Im going to argue with it LOL) thanx all for the feedback. it works great now
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top