<form action="" method="post">
<input type="text" name="name" />
<input type="submit" value="My Name Is .." />
</form>
<?php
$filename = "username.php" ;
$name = "" ;
$fh = fopen("$filename","w") or die ("Can't find $filename") ;
fwrite ($fh , $name) ;
fclose($fh);
$fh = fopen ($filename , "r") or die ("Can't find $filename") ;
$fstring = fread ($fh , filesize ($filename)) ;
echo "$fstring";
fclose($fh) ;
?>
when the variable $name has a name inserted it works fine it opens the file writes the name to it and then echos the files contents. My problem is the variable needs to remain blank as it pulls its information from the above form so onload of the page the user enters their name submits it and this passes their name onto the script who stores it then echos it were needed
So the question is how do I get the php script to wait for the user to enter their name and accept the blank file. the current error I get is
Warning: fread() [function.fread]: Length parameter must be greater than 0 in filepath/test.php on line 17
Any help would be great thanks
<input type="text" name="name" />
<input type="submit" value="My Name Is .." />
</form>
<?php
$filename = "username.php" ;
$name = "" ;
$fh = fopen("$filename","w") or die ("Can't find $filename") ;
fwrite ($fh , $name) ;
fclose($fh);
$fh = fopen ($filename , "r") or die ("Can't find $filename") ;
$fstring = fread ($fh , filesize ($filename)) ;
echo "$fstring";
fclose($fh) ;
?>
when the variable $name has a name inserted it works fine it opens the file writes the name to it and then echos the files contents. My problem is the variable needs to remain blank as it pulls its information from the above form so onload of the page the user enters their name submits it and this passes their name onto the script who stores it then echos it were needed
So the question is how do I get the php script to wait for the user to enter their name and accept the blank file. the current error I get is
Warning: fread() [function.fread]: Length parameter must be greater than 0 in filepath/test.php on line 17
Any help would be great thanks