nutt318 Posted February 10, 2009 Share Posted February 10, 2009 I have the following code when clicking the button in modifies a text file. Is there a way that I can click the button without the page refreshing? Basically there is a video feed on this same page and i have to restart it when clicking the button because it refreshes the page. <?php if($_POST['Submit']){ $open = fopen("test.txt","a+"); $text = "Left\n"; fwrite($open, $text); fclose($open); } echo "<form action=\"".$_SERVER['PHP_SELF']."\" method=\"post\">"; echo "<input name=\"Submit\" type=\"submit\" value=\"Left\" />\n </form>"; ?> Can I use a frame or a different type of php code? Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/144656-solved-click-button-without-page-refresh/ Share on other sites More sharing options...
Maq Posted February 10, 2009 Share Posted February 10, 2009 Not with PHP. You would have to use AJAX to make a server call without a page refresh. Quote Link to comment https://forums.phpfreaks.com/topic/144656-solved-click-button-without-page-refresh/#findComment-759048 Share on other sites More sharing options...
premiso Posted February 10, 2009 Share Posted February 10, 2009 You can use an IFRAME or look into AJAX. Quote Link to comment https://forums.phpfreaks.com/topic/144656-solved-click-button-without-page-refresh/#findComment-759052 Share on other sites More sharing options...
Goafer Posted February 10, 2009 Share Posted February 10, 2009 AJAX is definitely worth looking into, seems a bit hard at first but once you've worked out the dynamics of it, it is very useful. Quote Link to comment https://forums.phpfreaks.com/topic/144656-solved-click-button-without-page-refresh/#findComment-759057 Share on other sites More sharing options...
nutt318 Posted February 10, 2009 Author Share Posted February 10, 2009 Well it looks like I need to look at AJAX then. Is there a certain section or functions that I should be looking at in order to duplicate the PHP code? Thanks guys. Quote Link to comment https://forums.phpfreaks.com/topic/144656-solved-click-button-without-page-refresh/#findComment-759063 Share on other sites More sharing options...
mat-tastic Posted February 10, 2009 Share Posted February 10, 2009 Go here: http://www.phpfreaks.com/forums/index.php/topic,115581.0.html That will get you started on AJAX. Quote Link to comment https://forums.phpfreaks.com/topic/144656-solved-click-button-without-page-refresh/#findComment-759065 Share on other sites More sharing options...
nutt318 Posted February 10, 2009 Author Share Posted February 10, 2009 Thanks for the link mat-tastic. Quote Link to comment https://forums.phpfreaks.com/topic/144656-solved-click-button-without-page-refresh/#findComment-759100 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.