Jump to content

how to access php code by html events.


techrahul87

Recommended Posts

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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: :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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.