How to call php function on html button click.

I want to call php function defined in same file through html button.
Kindly correct the attached code.
Who is Participating?
Gurvinder Pal SinghConnect With a Mentor Commented:
In fact, this solution is doing exactly the same only

why ask the same question again?
OmniUnlimitedConnect With a Mentor Commented:
Should be:

<script type="text/javascript">
	function f()
		alert('India is great');
<form name="f">
<input type="Button" name="b1" value="click me" onClick="f()">

Open in new window

Minh Võ CôngConnect With a Mentor Commented:
html cannot call php function because html in client side and php is server side. it only call a javascript function.
On button click event you can call a javascript function and in js function you can call php script
or you can use AJAX
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Loganathan NatarajanConnect With a Mentor LAMP DeveloperCommented:
You can achieve this using Jquery well.

searchsanjaysharmaAuthor Commented:
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.