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

 

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.

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.