Button to run php file

I know this question is 5 years old, but for anybody wondering how to do this without re-rendering the main page. This solution uses the dart editor/scripting language.

You could have an tag that contains a data attribute. Make the 1px by 1px and then use something like dart to dynamically change the 's data attribute which re-renders the data in the 1px by 1px object.

HTML Script:




Start Script



someScript.php:


dartScript.dart:

import 'dart:html';

InputElement button1;
ObjectElement externalSource;

void main[] {
    button1 = querySelector['#button1']
        ..onClick.listen[runExternalSource];

    externalSource = querySelector['#external_source'];
}

void runExternalSource[Event e] {
    externalSource.setAttribute['data', 'someScript.php'];
}

So long as you aren't posting any information and you are just looking to run a script, this should work just fine.

Just build the dart script using "pub Build[generate JS]" and then upload the package onto your server.

View Discussion

Improve Article

Save Article

  • Read
  • Discuss
  • View Discussion

    Improve Article

    Save Article

    Given a document containing HTML and PHP code and the task is to call the PHP function after clicking on the button. There are various methods to solve this problem. Also, apart from doing this with the click of a button, a PHP function can be called using Ajax, JavaScript, and JQuery. But this article mainly focuses on the button oriented approach of calling the PHP Function.

    Calling a PHP function using the HTML button: Create an HTML form document which contains the HTML button. When the button is clicked the method POST is called. The POST method describes how to send data to the server. After clicking the button, the array_key_exists[] function called.

    Program 1:

        

            How to call PHP function

            on the click of a Button ?

        

        

            GeeksforGeeks

        

        

            How to call PHP function

            on the click of a Button ?

        

        

        

            

            

        

    Output:

    Let’s take a look with the GET or POST methods, as most developers use POST method due to privacy issues, the following example is based on POST method only:

    Program 2: This program uses isset[] function to call PHP function.

        

            How to call PHP function

            on the click of a Button ?

        

        

            GeeksforGeeks

        

        

            How to call PHP function

            on the click of a Button ?

        

        

        

            

            

        

    Output:


    How can I run my PHP file?

    php” file is placed inside the “htdocs” folder. If you want to run it, open any web browser and enter “localhost/demo. php” and press enter. Your program will run.

    Can I call PHP function on button click?

    You can't run PHP functions on the click of a button like this. You can do it in Javascript, however.

    How can I call a PHP file using an HTML button?

    Calling a PHP function using the HTML button: Create an HTML form document which contains the HTML button. When the button is clicked the method POST is called. The POST method describes how to send data to the server.

    How do I run a PHP file from a website?

    To run a PHP Web Page:.
    Click the arrow next to the Run button. on the toolbar and select Run Configurations -or- go to Run | Run Configurations. A Run dialog will open..
    Double-click the PHP Web Page option to create a new run configuration..

    Chủ Đề