ivn Posted August 14, 2010 Share Posted August 14, 2010 Hello I am working in moodle and its code base is in PHP. I am a novice to moodle as well as PHP and not quite familiar with PHP syntax. Right now I have built a Web page in moodle, and its view.php file I need to implement a fuctionality on click of a button. On click of submit button, I am trying to implement a functionality and I have written the code for that under if(isset($_POST['submit])) { ...my code...} Also while creating the form I have set the attributes as follows: echo "<form method='post' action='" . $_SERVER['PHP_SELF']."?inpopup=". $_GET['inpopup']."&id=" . $_GET['id'] . "'>"; But irrespective of whether or not I click the button, whenevr the page loads for the first time, it perform the code written in IF loop as well. So Am i going wrong in implementing a functionality on click of button in PHP or is it something related to moodle, if anyone knows? Any help or suggestions would be appreciated. As I am stuck with this logic since last three days. Regards Quote Link to comment https://forums.phpfreaks.com/topic/210707-cannot-submit-on-click-of-a-button-using-post-method/ Share on other sites More sharing options...
Pikachu2000 Posted August 14, 2010 Share Posted August 14, 2010 Paste your code here. Can't tell anything without seeing it. Quote Link to comment https://forums.phpfreaks.com/topic/210707-cannot-submit-on-click-of-a-button-using-post-method/#findComment-1099175 Share on other sites More sharing options...
ivn Posted August 14, 2010 Author Share Posted August 14, 2010 Well thanks for replying back. But I got a solution myself. I changed the logic entirely and thus now the button is just acting like a refresh button, and just loads the page. I have reverted the order of functions in such a way that now it does perfectly in order the functions its supposed to. Anyway thanks for replying back. Quote Link to comment https://forums.phpfreaks.com/topic/210707-cannot-submit-on-click-of-a-button-using-post-method/#findComment-1099254 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.