I have a form structure webpage written in PHP. When information is submitted it gives a unique ID.
Now I want this unique ID to be used in a file. For Example:
$input = "man.id: ".$id;
where $id
is the response from the webpage.
$input
is present in the same PHP file.
Here's an example of how to write (append) text to a file with PHP:
$id = GetID(); // GetID can return a value stored on disk that gets incremented
$input = "man.id: " . $id;
$logfile = "mypage.log";
$file = fopen($logfile, 'a'); // Try to open the file in Append mode
if($file) // If the file was opened successfully, i.e. if $file is a valid file pointer
{
flock($file, LOCK_EX); // Exclusive lock
fwrite($file, $input);
fclose($file);
}
精彩评论