Jump to content

form to flat file text script problem.


minnemike

Recommended Posts

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]
Link to comment
https://forums.phpfreaks.com/topic/26498-form-to-flat-file-text-script-problem/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.