html - Not writing (or even opening file) in php -


i read many of other questions on site revolving around error, none of able me, below php code takes data input html file , sends php file, after printing "hello name" on page, should open file called my_file.txt, created, , write it, have been unable so, great, here code:

index.html file:

<html> <head><title>hello friend</title></head> <body bgcolor="black"> <p style="text-align:center"> <font color="white"> <form action="data.php" method="post">     <input type="text" name="myname" id="myname">     <input type="submit" value="submit"> </form> </body> </html> 

data.php file:

<html> <head> <title>hello friend, php</title> </head> <body bgcolor="black"> <font color="white"> <code> <?php     $name = $_post["myname"];     echo "hello, " . $name;     $filename = "my_file.txt";     chmod($filename, 777);     $f = fopen($filename, "w") or die("unable open file");     fwrite($f, "the name is: " . $name);     f.close($f);     echo fgets($f);     fclose($f); ?> 

output:

hello, johnunable open file 

you want open file write. make sure file writable php process. check out http server rights on script folder data.php appears. enable more verbose php errors, can related many things (maybe hosting disabled fopen feature).


Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -