Useing HTML button to call PHP class

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
BrettCarr
Forum Newbie
Posts: 22
Joined: Fri Feb 12, 2010 6:45 pm

Useing HTML button to call PHP class

Post by BrettCarr »

Hi guys,
I'm trying to call a function that resides in a class call Batcharray from a page call batch.php from a button, I'm at a lose, here is my the code for the button

Code: Select all

$form->add( array('name' => 'arrayclear', 'type' => 'button', 'buttontype' => 'button', 'value' => 'Clear array', 'onclick'=> "location.href='/batch.php?&action=<? echo $batch->addDatadb();?>;'" , ) );
 
Basically the onclick event is where im struggling
Kurby
Forum Commoner
Posts: 63
Joined: Tue Feb 23, 2010 10:51 am

Re: Useing HTML button to call PHP class

Post by Kurby »

There are two ways to do this. The button can redirect the browser to the batch.php page, or you can use AJAX.

PHP is executed on the server so you need some sort of web request to run any PHP code.
Post Reply