button events wiht php

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
ps_sach
Forum Newbie
Posts: 3
Joined: Thu Mar 13, 2008 11:40 pm

button events wiht php

Post 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?
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Re: button events wiht php

Post 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.
Post Reply