...

View Full Version : I need help with this form script...



LRmaster
04-05-2003, 12:59 PM
The script is:

<?
function WriteToFile ($Name, $News) {
/* Function Write to File takes up two arguments - URL and News - which will be written to an external file. */
$TheFile = "data.txt";
$Open = fopen ($TheFile, "a");
if ($Open) {
fwrite ($Open, "$Name\t$News\n");
fclose ($Open);
$Worked = TRUE;
} else {
$Worked = FALSE;
}
return $Worked;
} // End of Write to File Function.
?>
<html>
<head>
<title>Using Files</title>
<body>
<?php
/* This page recieves and handles the data generated by "form.html". */
$Pattern = "(http://)?([^[:space:]]+)([[:alnum:]\.,-_?/&=])";
if (eregi($Pattern, $Array["Name"])) {
$Replace = "<a href=\"http://\\2\\3\" target=\"_new\">\\2\\3</a>";
$Array["Name"] = eregi_replace($Pattern, $Replace, $Array["Name"]);
$CallFunction = WriteToFile($Array["Name"], $Array["News"]);
if ($CallFunction) {
print ("Your submission-$Array[Name]-has been received!<br>\n");
} else {
print ("Your submission was not processed due to a system error!<br>\n");
}
} else {
print ("Please enter something\n");
}
?>
</body>
</html>


And I don't know which parts to take out, so that the Name will not be linked, ince I took this code from a book, and I would like to modify it. Thank you.

Weirdan
04-05-2003, 01:33 PM
cut this out:


$Replace = "<a href=\"http://\\\\2\\\\3\" target=\"_new\">\\\\2\\\\3</a>";
$Array["Name"] = eregi_replace($Pattern, $Replace, $Array["Name"]);

LRmaster
04-05-2003, 03:47 PM
Thank you. I'm gonna try it now.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum