techrahul87 Posted July 6, 2011 Share Posted July 6, 2011 hi everyone, i m new to php. all the coding I did in php is only on form submit. e.g if there is many buttons in one form and we have to perform different tasks. how will we do this in php. thanks for helping Quote Link to comment https://forums.phpfreaks.com/topic/241211-how-to-access-php-code-by-html-events/ Share on other sites More sharing options...
trq Posted July 6, 2011 Share Posted July 6, 2011 PHP executes server-side, so you need to make a request to the server in order to execute PHP. You might look into Ajax. Quote Link to comment https://forums.phpfreaks.com/topic/241211-how-to-access-php-code-by-html-events/#findComment-1238990 Share on other sites More sharing options...
techrahul87 Posted July 6, 2011 Author Share Posted July 6, 2011 hi, isn,t there any other way for it. like in c# we can make different functions for events by adding simply runat="server". and calling them. now i m getting really confused. please give an explanation....... :confused: Quote Link to comment https://forums.phpfreaks.com/topic/241211-how-to-access-php-code-by-html-events/#findComment-1238992 Share on other sites More sharing options...
dcro2 Posted July 6, 2011 Share Posted July 6, 2011 No, there's no events. When you go to a webpage, your browser requests the page from the web server, Apache for example. If the page is written in PHP, Apache then calls on PHP to process that page and then sends you whatever code PHP generated. After that the page in your browser is a done deal, no changes and no more communication to the web server. If you want to replace parts of the page or call a PHP script, you'll have to use Javascript to request that page from the server while your browser keeps displaying the same page. Quote Link to comment https://forums.phpfreaks.com/topic/241211-how-to-access-php-code-by-html-events/#findComment-1238995 Share on other sites More sharing options...
xyph Posted July 6, 2011 Share Posted July 6, 2011 PHP != C You want to check for certain values a form submission will give to PHP. Try using the code print_r( $_POST ); to get an idea of what those values are, depending on what button is pressed. PHP will use the name attributes of the HTML form elements as the array keys. Quote Link to comment https://forums.phpfreaks.com/topic/241211-how-to-access-php-code-by-html-events/#findComment-1238998 Share on other sites More sharing options...
trq Posted July 6, 2011 Share Posted July 6, 2011 hi, isn,t there any other way for it. like in c# we can make different functions for events by adding simply runat="server". and calling them. now i m getting really confused. please give an explanation....... :confused: C# (.net) uses Ajax in the background to make requests between the client and server. PHP won't hold your hand like that. You will need to develop both the client side & server side code to make the Ajax requests yourself. Using a framework like jQuery on the client side makes these things pretty simple though so I'm not sure what the issue is. Quote Link to comment https://forums.phpfreaks.com/topic/241211-how-to-access-php-code-by-html-events/#findComment-1239017 Share on other sites More sharing options...
techrahul87 Posted July 6, 2011 Author Share Posted July 6, 2011 thanks for that ajax thing now i m getting wts going on........... Quote Link to comment https://forums.phpfreaks.com/topic/241211-how-to-access-php-code-by-html-events/#findComment-1239029 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.