jeffery1493 Posted January 26, 2007 Share Posted January 26, 2007 Hi All,I have a PHP template that is constructed (greatly simplified) like this:$template-> assign_vars(array( 'L_HEADER_MESSAGE' => $lang['header_message'], // "Click here to execute function!" . . . 'ACTION' => perform_the_action(), . . . ) );$template-> pparse ('body');In the template, there is an icon which you click to execute. In the place of perform_the_action(), there used to be a web address, like http://www.paypal.com. This used to work fine, when you clicked the icon, you would then go to the paypal address.Instead however, I want to call the function: perform_the_action when the icon is clicked.The problem is, when PHP runs, it plows right through and immediately executes perform_the_action(), whether you click it or not.Is there some way to have a button in a template in PHP, so when you click it you execute a function in your program, but the function won't execute UNTIL you click it? I figure I'd save twelve hours of web hunting by asking.........Thanks for any advice,JEFFERY1493. Quote Link to comment Share on other sites More sharing options...
fert Posted January 26, 2007 Share Posted January 26, 2007 you'd need to use ajax or put the function on a separate php page and link to it Quote Link to comment Share on other sites More sharing options...
jeffery1493 Posted January 26, 2007 Author Share Posted January 26, 2007 I don't understand why PHP can't do simple things like this. Its almost like to program on PHP you have to first learn about 8 other languages (JavaScript, Ajax, MySql, Html, Curl......) :'(I understand it isn't an 'object oriented' language, but sheesh, I'm not painting the Sistine Chapel here.A PHP freak, I may not become.......... Quote Link to comment Share on other sites More sharing options...
jeffery1493 Posted January 26, 2007 Author Share Posted January 26, 2007 [b]PHP[/b]- Practically Half Provided Quote Link to comment Share on other sites More sharing options...
Jessica Posted January 26, 2007 Share Posted January 26, 2007 OR, PHP stands for PHP: Hypertext Preprocessor.PRE- meaning BEFORE. Meaning it's designed to handle scripting on html pages before they out processed by the browser. It originally mean Personal Home Pages. It's not meant to imitate a desktop application, in which you could press a button and have a function run. In PHP, in order to run new code, you have to load a new page. This is basic stuff. AJAX and CURL help provide ways to imitate a desktop app, like what you want. Complaining about having to know about html is like complaining about having to know how to use a pencil when you just want to write a little note! PHP is designed to be used IN html pages and with databases. You don't have to use MySQL with PHP, but it makes it faster and easier than using flatfiles for everything you want to persist. Other languages interact with files and dbs as well, it's called "Persistent Storage".ANYWAY, AJAX is NOT hard. The mootools framework uses one freaking line of JS in order to do what you want. Chillax. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.