Could someone knowing Perl or PHP help me?

child of wonder

Diamond Member
Aug 31, 2006
8,307
176
106
My boss came to me today and tasked me with making a simple web page containing a company memo and to have at the bottom a spot where those who read it can enter their first name in one field and their last name in a second field then click "Submit" to verify they've read the memo.

I got the HTML portion up without any problem. Here's what I have for the form part:

<form method=post action="data.pl">
Enter your first name:
<input name="firstname">
<br><br>Enter your last name:
<input name="lastname">
<br><br>
I have read and accept this memo.
<br><br>
<input type="submit" value="Submit">
</form>

The problem I'm having is that I don't know jack about Perl or PHP to get it to simply take the first name, last name, and the current date and append it to a text file as different employees read and submit their information. Eventually we'd like to have a long text file like so:

John Doe 11/2/2007
Jane Doe 11/2/2007
Jim Doe 11/2/2207
etc...

Can anyone give me some pointers or point me to a guide to get me started?

Any help would be appreciated.
 

Hmongkeysauce

Senior member
Jun 8, 2005
360
0
76
<?php
$file = "myfile.txt";
$openfile = fopen($file, 'a') or die ("can't open file");
$dataString = $_POST['firstname']." ".$_POST['lastname']." ".date("M/d/Y", time())."\n";
fwrite($openfile, $dataString);
fclose($openfile);
?>

something similar to that context.
 

reverend boltron

Senior member
Nov 18, 2004
945
0
76
I would do something along these lines..

for the HTML I would do

<html>
<head>
<title>Employee Verification Page</title>
</head>

<body>

<!-- Change the "action" to point at your PHP page! -->

<form method="POST" action="listupdate.php">
Enter your first name:
<input name="firstname" type="TEXT">
<br><br>Enter your last name:
<input name="lastname" type="TEXT">
<br><br>
I have read and accept this memo.
<br><br>
<input type="SUBMIT" value="Submit">
</form>

</body>

</html>



for the PHP I would do

<?php

//trim just gets rid of white space at the beginning and end of names
$first = trim($_POST['firstname']);
$last = trim($_POST['lastname']);
$datestring = date("m/d/Y");
//whatever you want to name the file
$myFile = "view_memo.txt";

$fh = fopen($myFile, 'a') or die("can't open file");
$stringData = "$first $last $datestring\n";
fwrite($fh, $stringData);
fclose($fh);

?>
 

child of wonder

Diamond Member
Aug 31, 2006
8,307
176
106
Thanks for everyone's help! The script works like a charm and does exactly what we need it to.

My hat is off. :)