Location: PHPKode > scripts > PHP Form2Text > php-form2text/form2txt.php
<?php
/******************************************************************************\
* PHP Form 2 Text                              Version 1.0                     *
* Copyright 2000 Frederic TYNDIUK (FTLS)       All Rights Reserved.            *
* E-Mail: hide@address.com                     Script License: GPL             *
* Created  02/28/2000                          Last Modified 02/28/2000        *
* Scripts Archive at:                          http://www.ftls.org/php/        *
*******************************************************************************/
// Necessary Variables:

$MESSAGE_FILE = "form2txt_data.txt";
	// En: result file
	// Fr: fichier resultat.
	
$DEFAULT_EXIT_PAGE = "http://www.ftls.org/";
	// En: exit page.
	// Fr: page de sortie.

// 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

?> 
Return current item: PHP Form2Text