Hey guys,
i am trying to make a button that will execute a php function that i have in the same page.
Can some please give me an example of how to do this?
Thanks,
Kinga
executing a php function from either html or java script
Moderator: General Moderators
-
lettie_dude
- Forum Commoner
- Posts: 65
- Joined: Thu Dec 07, 2006 10:10 am
Place the following in the form tag:
This will submit the page to itself.
Then add your function code to the top of the page.
Wrap this in something like:
Then the code will only process when the submit button or whatever you call it is actioned.
Code: Select all
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">Then add your function code to the top of the page.
Wrap this in something like:
Code: Select all
if(isset($_POST['submit'])) {
// Your code
}