Calling a PHP function from an HTML form in the same file

后端 未结 10 1459
无人共我
无人共我 2020-12-05 05:48

I\'m trying to execute a PHP function in the same page after the user enters a text and presses a submit button.

The first I think of is using forms. When the user s

10条回答
  •  醉酒成梦
    2020-12-05 06:28

    That's now how PHP works. test() will execute when the page is loaded, not when the submit button is clicked.

    To do this sort of thing, you have to have the onclick attribute do an AJAX call to a PHP file.

提交回复
热议问题