How do I make this work? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How do I make this work?

<html> <head> <title>Page Title</title> </head> <body> <form action="myprocessingscript.php" method="POST"> <input name="field1" type="text" /> <input name="field2" type="text" /> <input type="submit" name="submit" value="Save Data"> </form> <?php $txt = "data.txt"; $fh = fopen($txt, 'w+'); if (isset($_POST['field1']) && isset($_POST['field2'])) { // check if both fields are set $txt=$_POST['field1'].' - '.$_POST['field2']; file_put_contents('data.txt',$txt."\n",FILE_APPEND); // log to data.txt fwrite($fh,$txt); // Write information to the file fclose($fh); // Close the file exit(); } ?> </body> </html>

14th Dec 2016, 8:33 PM
Dania Miller
Dania Miller - avatar
1 Answer
0
leave action="" blank so it will post data to itself hope you got my point
15th Dec 2016, 8:03 PM
imran ali
imran ali - avatar