<?php
if($_POST['posted']){
//getting value of post
$user_name=htmlspecialchars($_POST['usr_name']."\r\n");
}
//open file to reading and writing
$fp=fopen("name.txt","a+");
if(!$fp) die("Cannot open the file");
fwrite($fp,$user_name);
fclose($fp);
$file="./name.txt";
//getting file Info
$file_size=$_FILES['userfile']['size'];
$read=file_get_contents($file);
$line=explode("\n",$read);
foreach($line as $newline){
echo "<font face='Times New Roman'><i>".$newline."</font></i><br>";
}
echo "The File Size is : ".filesize($file).' bytes<br>';
$lines = count(file($file));
echo "There are $lines lines in this file<br>";
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
<meta name="author" content="niceabi" />
<title>Name box</title>
</head>
<body>
<table border="1" align="center">
<form method="post" action="name.php">
Enter Your Name :
<input type="text" name="usr_name">
<input type="hidden" value="true" name="posted">
<input type="submit" value="submit">
</form>
</table>
</body>
</html>
Bookmarks