单击按钮调用PHP函数[复制]

This question already has an answer here:

This is the PHP function, it is messy right now (redundant lines) that I will clean up after. I am stuck right now, really trying to keep the whole process to one page:

<?php function signpetitiion() {
$API_KEY = 'MYAPIKEY';
$REQUEST_URL = 'https://api.change.org/v1/petitions/get_id';
$PETITION_URL = 'https://www.change.org/p/URLTOMYPETITION';
$parameters = array(
  'api_key' => $API_KEY,
  'petition_url' => $PETITION_URL

}


?>

So this doesn't work because it is browser side:

<form onsubmit="sign_petitiion()">

How do I get this function to run with a button click? Should I convert to a JS script? if so how?

Or call with AJAX? if so how?

if(isset($_POST['go'])){

    <input type="submit" name="go" method="post">

Question closed as I was typing my answer

I know this question (in different ways) has been asked before, I had read through them but the answers were either too complicated for me (NEWB) or just a comment saying you can't.

Any ways I have found my answer,

I had to change these 2 lines

function sign_petitiion() {

to

     if(isset($_POST['go'])){

and then

<form onsubmit="sign_petitiion()">

to

    <form method="Post" class="sign" action="mypage.php">
</div>
<!-- HTML-->
<a href='index.php?run=true'>Execute it </a>

//*.php
if($_Get['true']){
    signpetitiion();
}