Currently doing network systems at college, and I'm trying to figure out how to append a date/time doodah to a text file. Html:
Code:
<html>
<head>
<title>Student Information Form</title>
</head>
<body bgcolor="#000000" text="#ffffff" link="#0000ff" vlink"#800080" alink="#ff0000">
<form action="/cgi-bin/assignment1.php" method="post">
<H2>Student Information Form</H2>
<HR>
<B>Student Information:</B>
<BR><I>First Name </I><input type="text" name="firstname" size="12" maxlength="15">
<BR><I>Surname </I><input type="text" name="surname" size="12" maxlength="15">
<BR><I>Date of Birth </I><input type="text" name="dob" size="12" maxlength="10">
<BR><I>House Number </I><input type="text" name="housenumber" size="12"
maxlength="10">
<BR><I>Street Name </I><input type="text" name="streetname" size="12"
maxlength="20">
<BR><I>Town/City </I><input type="text" name="towncity" size="12" maxlength="15">
<BR><I>Postcode </I><input type="text" name="postcode" size="12" maxlength="10">
<BR><I>Course Name </I><input type="text" name="course" size="12" maxlength="20">
<BR><I>Student ID. </I><input type="text" name="studentid" size="12"
maxlength="10">
<BR>
<BR><input type="reset" value="Clear Form">
<BR>
<BR><input type="submit" value="Submit Information">
</form>
<HR>
</body>
</html>
PHP Code:
<html>
<head>
<title>Student Information Form</title>
</head>
<body>
<?php
print "<BR>Your information has been received, and has been logged on: \n";
echo date ("j/m/Y ( H:i:s )");
print "<BR>Your completed form details are displayed below.\n";
$firstname = $_POST["firstname"];
$surname = $_POST["surname"];
$dob = $_POST["dob"];
$housenumber = $_POST["housenumber"];
$streetname = $_POST["streetname"];
$towncity = $_POST["towncity"];
$postcode = $_POST["postcode"];
$course = $_POST["course"];
$studentid = $_POST["studentid"];
print "<BR><BR>First name = $firstname\n";
print "<BR>Surname = $surname\n";
print "<BR>Date of birth = $dob\n";
print "<BR>House Number = $housenumber\n";
print "<BR>Street Name = $streetname\n";
print "<BR>Town/City = $towncity\n";
print "<BR>Postcode = $postcode\n";
print "<BR>Course Name = $course\n";
print "<BR>Student ID. = $studentid\n";
print "<BR><BR>";
$filename ='c:\temp\tmsfeedback.doc';
$fp = fopen( $filename , "a");
fputs($fp,"\nFirstname=$firstname");
fputs($fp,"\n===============");
fputs($fp,"\nSurname=$surname");
fputs($fp,"\n===============");
fputs($fp,"\nDate of Birth=$dob");
fputs($fp,"\n===============");
fputs($fp,"\nHouse Number=$housenumber");
fputs($fp,"\n===============");
fputs($fp,"\nStreet Name=$streetname");
fputs($fp,"\n===============");
fputs($fp,"\nTown/City=$towncity");
fputs($fp,"\n===============");
fputs($fp,"\nPostcode=$postcode");
fputs($fp,"\n===============");
fputs($fp,"\nCourse Name=$course");
fputs($fp,"\n===============");
fputs($fp,"\nStudent ID.=$studentid");
fputs($fp,"\n===============");
fputs($fp,"\n===============");
fputs($fp,"\n===============");
fclose($fp);
?>
</body>
</html>
I'm fine with all the above, however I have to append a date for every entry in the text file. I've been using
echo date ("j/m/Y ( H:i:s )");
to show date/time in the feedback php form, but I can't figure how to append it.
I'm guessing I'd have to create a local variable, but I have little clue how to do this other than with pre-defined html named variables, as shown above.
Help, please?