php - Submit html form without refresh or jquery -
i making webpage has html form in , php code process form data. want make doesnt refresh page after each button press , save data file? how go doing this?
here code:
<html> <head> </head> <body> <form method="post" action="out.php"> <input type="submit" name="foo" value="a" /> <input type="submit" name="foo" value="b" /> <input type="submit" name="foo" value="c" /> <input type="submit" name="foo" value="d" /> <input type="submit" name="foo" value="e" /> <input type="submit" name="foo" value="f" /> <input type="submit" name="foo" value="g" /> </form> <?php $name = $_post['foo']; $fp = fopen("formdata.txt", "w"); fwrite($fp, ""); $savestring = $name; fwrite($fp, $savestring); fclose($fp); ?> </body> </html>
if you're avoiding javascript altogether, can target hidden iframe.
css:
iframe.hidden{ display:none } html:
<iframe name="iframe" width="0" height="0" tabindex="-1" class="hidden"></iframe> <form method="post" action="out.php" target="iframe">... however, you're better off using javascript ensure data has submitted properly. if user's session has expired? if internet connection unstable? how know data validated ok?
Comments
Post a Comment