Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Run PHP code on button click

Tags:

html

php

What is the best way to just run a PHP script when the user clicks a button? It sends nothing back to the user whatsoever! (The PHP script only sends a PostgreSQL query.)

I have only found ways of returning data. I only want to run it.

like image 389
user1431627 Avatar asked Dec 18 '25 17:12

user1431627


1 Answers

You're looking for AJAX (asynchronous javascript). Just have a javascript function call the target script and either don't return anything OR don't do anything with the return value. Alternately, you could simply have form that submits to a hidden iframe on the page.

like image 168
Ben D Avatar answered Dec 21 '25 11:12

Ben D



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!