code: <?php if(isset($_POST['submit'])) { $name = $_POST['name']; $name = $name."\n"; $date = $_POST['date']; $date = $date."\n"; $number = $_POST['number']; $number = $number."\n\n"; //Change the name of the textfile to whatever you need to. Put it in the same folder as this file. $ourFileName = "textfile.txt"; $fh = fopen($ourFileName, 'a') or die("Can't open file"); fwrite($fh, $name.$date.$number); fclose($fh); echo "<table width=100% height=100% align=center><tr align=center valign=middle><td><font face=arial size=2><b>Entry added. <a href=javascript:history.back()>Go back.</a></b></font></td></tr></table>"; } else { ?> <html> <head> <title>Enter some information</title> </head> <table width=100% height=100% align=center> <tr valign=middle align=center> <td> <form method="post"> <table width=450 align=center style="border: 1px solid black;" cellspacing=0 border=0> <tr align=center> <td bgcolor="#EEEEEE" colspan=2><font face=arial size=2><b>Enter some information:</b></font></td> </tr> <td width=450> <table align=center> <tr align=center> <td width=25 align=left><font face=arial size=2>Name:</font></td> <td><input type="text" name="name"></td> </tr> <tr align=center> <td width=25 align=left><font face=arial size=2>Date:</font></td> <td><input type="text" name="date"></td> </tr> <tr align=center> <td width=25 align=left><font face=arial size=2>Number:</font></td> <td><input type="text" name="number"></td> </tr> <tr align=center> <td colspan=2><input type="submit" name="submit" value="Enter Information"></td> </tr> </table> </td> </tr> </table> </form> </td> </tr> </table> </html> <? } ?>
<?php if(isset($_POST['submit'])) { $name = $_POST['name']; $name = $name."\n"; $date = $_POST['date']; $date = $date."\n"; $number = $_POST['number']; $number = $number."\n\n"; //Change the name of the textfile to whatever you need to. Put it in the same folder as this file. $ourFileName = "textfile.txt"; $fh = fopen($ourFileName, 'a') or die("Can't open file"); fwrite($fh, $name.$date.$number); fclose($fh); echo "<table width=100% height=100% align=center><tr align=center valign=middle><td><font face=arial size=2><b>Entry added. <a href=javascript:history.back()>Go back.</a></b></font></td></tr></table>"; } else { ?> <html> <head> <title>Enter some information</title> </head> <table width=100% height=100% align=center> <tr valign=middle align=center> <td> <form method="post"> <table width=450 align=center style="border: 1px solid black;" cellspacing=0 border=0> <tr align=center> <td bgcolor="#EEEEEE" colspan=2><font face=arial size=2><b>Enter some information:</b></font></td> </tr> <td width=450> <table align=center> <tr align=center> <td width=25 align=left><font face=arial size=2>Name:</font></td> <td><input type="text" name="name"></td> </tr> <tr align=center> <td width=25 align=left><font face=arial size=2>Date:</font></td> <td><input type="text" name="date"></td> </tr> <tr align=center> <td width=25 align=left><font face=arial size=2>Number:</font></td> <td><input type="text" name="number"></td> </tr> <tr align=center> <td colspan=2><input type="submit" name="submit" value="Enter Information"></td> </tr> </table> </td> </tr> </table> </form> </td> </tr> </table> </html> <? } ?>