sx Posted April 11, 2007 Share Posted April 11, 2007 I have a function example: function wipepostkillfred($post2,$name,$reason,$datestarted,$mdhash) { echo "hahahahahahahahahah"; } I want to trigger this function using a button. How can I do this? Link to comment https://forums.phpfreaks.com/topic/46622-triggering-a-funciton-using-a-button/ Share on other sites More sharing options...
soycharliente Posted April 11, 2007 Share Posted April 11, 2007 Create a button and give it a name. Post that name to whatever page the form directs to. if(isset($_POST["button_name"])) { callFunction(); } Try something like that. Link to comment https://forums.phpfreaks.com/topic/46622-triggering-a-funciton-using-a-button/#findComment-227017 Share on other sites More sharing options...
poirot Posted April 11, 2007 Share Posted April 11, 2007 You might as well use iframes and javascript - so you don't need to redirect to a new page. It depends on what you want to do... Link to comment https://forums.phpfreaks.com/topic/46622-triggering-a-funciton-using-a-button/#findComment-227021 Share on other sites More sharing options...
per1os Posted April 11, 2007 Share Posted April 11, 2007 Well if he wants it to not have to leave the page, iframes work, but AJAX would be better if you are going to use JavaScript anyways. This way the button is clicked it makes a trip to the page runs the function and returns back any data and you can display the results using this same way, with no refreshing period. But as poirot said, it all depends on what you want to do. Link to comment https://forums.phpfreaks.com/topic/46622-triggering-a-funciton-using-a-button/#findComment-227022 Share on other sites More sharing options...
sx Posted April 11, 2007 Author Share Posted April 11, 2007 I am actually running a script that goes into a mysql database, pulls a post and changes that post then replaces the old post in the database with the new one. It does not have to return anything to me other than "Complete". Link to comment https://forums.phpfreaks.com/topic/46622-triggering-a-funciton-using-a-button/#findComment-227030 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.