Run a PHP function upon button click?

前端 未结 8 1741
小鲜肉
小鲜肉 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条回答
  •  猫巷女王i
    2021-01-03 04:46

    This is a little complicated. You can either submit the form to itself, check to see if the post variable is set (if it is, then the page is being run because the form was submitted to it), or you can use ajax. The first is an easier solution, and the second doesn't require a page reload. Pick your poison ;)

    Look at this for the first solution, and look at jquery's ajax functions for the second.

提交回复
热议问题