boemboem Posted January 12, 2009 Share Posted January 12, 2009 the code below is for write to a text file from a form field. This piece is the only piece I could find. It works good but gives me the folowing outcome: Below is the result of your feedback form. It was submitted on Monday, January 12th, 2009 at 11:42 PM. Url : www.coldcharlie.nl Button : Submit But I would like to have the following: Below is the result of your feedback form. It was submitted on Monday, January 12th, 2009 at 11:42 PM. www.coldcharlie.nl this is because I extract these urls to put them later in a array can somebody help me please? <?PHP ###################### Set up the following variables ###################### # # $filename = "text.txt"; #CHMOD to 666 $forward = 0; # redirect? 1 : yes || 0 : no $location = "thankyou.htm"; #set page to redirect to, if 1 is above # # ##################### No need to edit below this line ###################### ## set time up ## $date = date ("l, F jS, Y"); $time = date ("h:i A"); ## mail message ## $msg = "Below is the result of your feedback form. It was submitted on $date at $time.\n\n"; foreach ($_POST as $key => $value) { $msg .= ucfirst ($key) ." : ". $value . "\n"; } $fp = fopen ($filename, "a"); # w = write to the file only, create file if it does not exist, discard existing contents if ($fp) { fwrite ($fp, $msg); fclose ($fp); } else { $forward = 2; } if ($forward == 1) { header ("Location:$location"); } else if ($forward == 0) { echo ("Thank you for submitting our form. We will get back to you as soon as possible."); } else { "Error processing form. Please contact the webmaster"; } ?> Quote Link to comment Share on other sites More sharing options...
Psycho Posted January 12, 2009 Share Posted January 12, 2009 Change this: foreach ($_POST as $key => $value) { $msg .= ucfirst ($key) ." : ". $value . "\n"; } To this: $msg .= $_POST['Url'] . "\n"; Quote Link to comment Share on other sites More sharing options...
boemboem Posted January 12, 2009 Author Share Posted January 12, 2009 that's not working It does run the handler, but it does not write to the text.txt edit: It is working when Url = changed to url Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.