I have a form on ‘contact.php’ which posts to ‘thankyou.php’ page that contains a function to capture the form ouput and write to a file. I can’t see any thing wrong with the syntax but I get a ‘Notice: Undefined index: txt_email in C:\wamp\www\o2aaic\smartsteps\ hankyou.php on line 86’ error. I can test if its set to stop the error but I can’t see what I’ve missed to actually pull in the post request.
function appendText() {
$file = "e_address.txt";
$fh = fopen($file, 'a') or exit("can't open file");
//Check file is writable and form data is set
if(is_writable($file) && isset($_POST['txt_email']))
{
$fh = fopen($file, 'a') or exit("can't open file");
$stringData = $_POST["txt_email"];
fwrite($fh, $stringData);
echo "SUCCESS";
fclose($fh);
}
else
{
// Polite error message to be defined
}
}
I’ve not done much php coding recently so I’m a little rusty but any help would be appreciated
Thanks, Des