Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

How to call php function on html button click.

Posted on 2011-09-06
6
866 Views
Last Modified: 2012-05-12
I want to call php function defined in same file through html button.
Kindly correct the attached code.
 htmlphp.php
0
Comment
Question by:searchsanjaysharma
6 Comments
 
LVL 40

Accepted Solution

by:
gurvinder372 earned 100 total points
ID: 36487161
In fact, this solution is doing exactly the same only
http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/Q_27292579.html

why ask the same question again?
0
 
LVL 17

Assisted Solution

by:OmniUnlimited
OmniUnlimited earned 100 total points
ID: 36487166
Should be:

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

Open in new window

0
 
LVL 15

Assisted Solution

by:Minh Võ Công
Minh Võ Công earned 200 total points
ID: 36487236
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
http://forums.devarticles.com/javascript-development-22/calling-php-functions-with-javascript-3471.html
http://www.daniweb.com/web-development/php/threads/20972
0
Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

 
LVL 15

Assisted Solution

by:Minh Võ Công
Minh Võ Công earned 200 total points
ID: 36487273
0
 
LVL 36

Assisted Solution

by:Loganathan Natarajan
Loganathan Natarajan earned 100 total points
ID: 36487671
You can achieve this using Jquery well.

Example
0
 

Author Closing Comment

by:searchsanjaysharma
ID: 36909729
Good
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
In this tutorial viewers will learn how to style a corner ribbon overlay for an image using CSS Create a new class by typing ".Ribbon":  Define the class' "display:" as "inline-block": Define its "position:" as "relative": Define its "overflow:" as …
In this tutorial viewers will learn how to embed videos in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <video> tag to insert a video. Define the src as the URL of your video; this is similar to …

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question