Jump to content

Cannot submit on click of a button using POST method


ivn

Recommended Posts

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

 

Link to comment
Share on other sites

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.

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.