Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
HELP!! function and button error
Old 09-06-2007, 08:56 PM HELP!! function and button error
Skilled Talker

Posts: 65
Trades: 0
i have created a button in my form (type=button) and on the onClick event, I need to execute some php code or some particular function
I don't want to create a submit button instead because cause i want to call different function when different button clicked how should i do that?
Code:
<head> 
<title>My Variables HTML Form</title> 
</head> 
<body> 
<h4>My HTML Form</h4> 
<?php
if (isset($_POST['action']) && $_POST['action'] == 'submitted') {
 
    echo "SUBMITTED BUTTON";
    //calling function
   display();
} 
else {
   echo "ME BUTTON";
 
    profile();
 
}
function display()
{
 echo "you called display function";
}
function profile()
{
 echo "you called Profile function";
}
?>  
 
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
    Name:  <input type="text" name="personal[name]" /><br />
    Email: <input type="text" name="personal[email]" /><br />
        <input type="button" name="action" value="submitted" />
    <input type="button" name="submit" value="submit me!" />
</form>
 
</body> 
</html>
The program could not work and once runned it display directly "ME BUTTONyou called Profile function" how to correct the program so it runs only when it clicked according to the button triggered?
leolim is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 09-06-2007, 10:35 PM Re: HELP!! function and button error
mgraphic's Avatar
Truth Seeker

Latest Blog Post:
JAMISONTUNES
Posts: 2,918
Name: Keith Marshall
Location: Connecticut
Trades: 0
You could use input submit buttons for both and then give each of them a unique name. Then using isset() in php you can determine which button was clicked.
__________________

<mgraphic /> - I don't have a solution but I admire the problem.
mgraphic is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to HELP!! function and button error
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.11343 seconds with 12 queries