George W. Bush
06-02-2001, 10:25 PM
I would like to find some information that will allow me to do such a thing. I do not undestand the commands that open the text file and write the form information into it. I am interested in having one log file where inside it I would have all the information.
In this script, there are 2 files. The form and a text file where the information is written to.
The form writes fine to the text file. But it writes the contents of each field on one line and it throws a tab between them so you can read them easier. The names of each field are NOT written, only the content. I would also like to write the names of the field followed by the content that was inputed in a format as:
LOGIN:
PASSWORD:
FULL NAME:
URL:
Right now it writes the content only in a straight line separated by a tab. But I am having problems adding the field names as above then have the content follow it.
The script is easy to go through, yet I do not see what I am missing...
1) The small form with PHP that writes to the text (result.txt) file is here and it is very small and does the work well, except what I would like to accomplish:
<HTML>
<HEAD>
<?
$file_name = "result.txt";
?>
<BODY>
<?
if ($insert) {
// check existence of file (or try to create it)
$try = touch($file_name);
if (!$try)
{
echo "Sorry file can't be opened";
exit;
}
// content from form inserted it into an array
$input = array ($login, $password, $fullname, $url);
// tabs inserted between the form element content
$output_line = implode ($input, " ")."\n";
// open the file (get a file pointer)
$output_stream = fopen($file_name, "a");
// dump the string into the text file
$result = fputs ($output_stream, $output_line);
// close the file pointer
fclose($output_stream);
?>
<?
//exit and the first bracket is closed here
exit;
}
?>
<FORM METHOD="POST" "<? echo $PHP_SELF; ?>">
....the form then comes here....
</FORM>
</BODY>
</HTML>
Very small but I cannot tell it to write the field names (headings) and content in a vertical format like:
LOGIN:
PASSWORD:
FULL NAME:
URL:
and not horizontal with tabs.
I would appreciate your extertise in this. Thank you once again!
In this script, there are 2 files. The form and a text file where the information is written to.
The form writes fine to the text file. But it writes the contents of each field on one line and it throws a tab between them so you can read them easier. The names of each field are NOT written, only the content. I would also like to write the names of the field followed by the content that was inputed in a format as:
LOGIN:
PASSWORD:
FULL NAME:
URL:
Right now it writes the content only in a straight line separated by a tab. But I am having problems adding the field names as above then have the content follow it.
The script is easy to go through, yet I do not see what I am missing...
1) The small form with PHP that writes to the text (result.txt) file is here and it is very small and does the work well, except what I would like to accomplish:
<HTML>
<HEAD>
<?
$file_name = "result.txt";
?>
<BODY>
<?
if ($insert) {
// check existence of file (or try to create it)
$try = touch($file_name);
if (!$try)
{
echo "Sorry file can't be opened";
exit;
}
// content from form inserted it into an array
$input = array ($login, $password, $fullname, $url);
// tabs inserted between the form element content
$output_line = implode ($input, " ")."\n";
// open the file (get a file pointer)
$output_stream = fopen($file_name, "a");
// dump the string into the text file
$result = fputs ($output_stream, $output_line);
// close the file pointer
fclose($output_stream);
?>
<?
//exit and the first bracket is closed here
exit;
}
?>
<FORM METHOD="POST" "<? echo $PHP_SELF; ?>">
....the form then comes here....
</FORM>
</BODY>
</HTML>
Very small but I cannot tell it to write the field names (headings) and content in a vertical format like:
LOGIN:
PASSWORD:
FULL NAME:
URL:
and not horizontal with tabs.
I would appreciate your extertise in this. Thank you once again!