Run a PHP function upon button click?

前端 未结 8 1666
小鲜肉
小鲜肉 2021-01-03 04:24

I want to run a PHP function with an HTML button click.

I can call a PHP script this way:

Name
8条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-03 04:40

    You can have the following approaches:

    1> Use AJAX to load "action.php" with the data entered in the fields as POST to the page and then take the response and put it into the body; or,

    2> You cannot make it work as PHP is a server-side programming language and HTML which you are trying to use with PHP is a client side programming language. So there is no way to make it work other than AJAX.

提交回复
热议问题