Page 1 of 1

Useing HTML button to call PHP class

Posted: Fri Feb 26, 2010 1:19 am
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

Re: Useing HTML button to call PHP class

Posted: Fri Feb 26, 2010 9:55 am
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.