<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "[URL unfurl="true"]http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">[/URL]
<html xmlns="[URL unfurl="true"]http://www.w3.org/1999/xhtml">[/URL]
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>
<body>
<form action="<?=$_SERVER['PHP_SELF']?>" method="post">
Type your name: <input type="text" name="uname" /><br/>
Type a place: <input type="text" name="uplace" /><br/>
<input type="submit" name="submit" value="Go" />
</form>
<hr/>
<?php
$filename = "data.txt";
if (isset($_POST['submit'])):
$uname = empty($_POST['uname']) ? "Anonymous" : trim($_POST['uname']);
$uplace = empty($_POST['uplace']) ? "No Place Provided" : trim($_POST['uplace']);
if(!get_magic_quotes_gpc()):
$uname = addslashes($uname);
$uplace =addslashes($uplace);
endif;
$fh = fopen($filename, "a+bt") or die("Can't open storage file");
fwrite ($fh, "\"$uname\",\"$uplace\"\r\n") or die("Cannot write to the storage file");
fclose ($fh);
endif;
$i = 0;
$fh = @fopen($filename, "rb") or die("Nothing Uploaded Yet");
$content = "<table border=\"1\">\r\n<tr><td>Person</td><td>Place Name</td></tr>\r\n";
while (($data = fgetcsv($fh, 2024, ",")) !== FALSE):
$content .= "<tr><td>{$data[0]}</td><td>{$data[1]}</td></tr>\r\n";
$i++;
endwhile;
fclose($fh);
$content .= "</table>";
if ($i === 0):
$content = "Nothing uploaded yet";
else:
echo $content;
endif;
?>
</body>
</html>