minnemike Posted November 7, 2006 Share Posted November 7, 2006 This worked at my old web host. It takes form data from a standard html page, gets called and writes it to a flat text file. Now it just runs and outputs a file with the current date only without any errors. Anyone have any idea what is wrong here?[code]<?php// Necessary Variables:$MESSAGE_FILE = "textdata.txt"; // result file$DEFAULT_EXIT_PAGE = "http://www.yoursite.com/"; // exit page.// End Necessary Variables section/******************************************************************************/function error($error_message) { echo $error_message."<BR>"; exit;}function check_referer () { global $REFERERS, $HTTP_REFERER; if ($HTTP_REFERER != "") while (list($val, $ref) = each($REFERERS)) if (preg_match("/^http:\/\/$ref/", $HTTP_REFERER)) return; error("Unauthorized access to: $HTTP_REFERER");}#check_referer();$message = "date : ".date("d/m/Y")."<BR>";while (list($key, $val) = each($HTTP_POST_VARS)) { $message .= "$key : ".htmlspecialchars($val)."<BR>";}$message = preg_replace("/\n\r*/", "<BR>", $message);$file_arry = file($MESSAGE_FILE); //or error("Can not open \$MESSAGE_FILE");$file = join ("", $file_arry);$message .= "\n".$file;$fp = fopen("$MESSAGE_FILE", "w"); // error("Can not write \$MESSAGE_FILE");flock($fp, 1);fputs($fp, $message);flock($fp, 3);fclose($fp);if(! $exit_page) $exit_page = $DEFAULT_EXIT_PAGE;Header("Location: ".$exit_page); // Exit -> $exit_page?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/26498-form-to-flat-file-text-script-problem/ 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.