Page 1 of 1

button events wiht php

Posted: Sun Mar 16, 2008 12:29 am
by ps_sach
consider the following code .....
<form name="form1" action="" method="post">
<input type="button" name="mybutton" onclick="<?php a_php_function(); ?>;
form1.submit()">
</form>


I want to run a php function when the button is clicked and before the form
is submitted. Does anyone know how this can be done?

Re: button events wiht php

Posted: Sun Mar 16, 2008 12:31 am
by RobertGonzalez
Ajax. PHP runs on the server not in the client so what you are wanting to do will fail every time.

You could tie a javascript event that calls a PHP file remotely to get what you want though.