gajubhai Posted May 12, 2010 Share Posted May 12, 2010 Dear All, I am from ASP.NET back ground and new to PHP. I just started learning the PHP for my new assignment but I could not understand how to handle Postback. My PHP page has many controls which can do post back. Each control has to do different task on postback. It can be easily done using control's event in the ASP.NET but I wonder how can it be done in PHP. How to make PHP page such that it will execute different code on post back caused by differnt controls. This might be fullish query but please help. Also anybody could suggest be good PHP book for this? Quote Link to comment Share on other sites More sharing options...
trq Posted May 12, 2010 Share Posted May 12, 2010 For those of us with no experience in .net you will need to describe exactly what a postback actually is / does. Quote Link to comment Share on other sites More sharing options...
gajubhai Posted May 12, 2010 Author Share Posted May 12, 2010 post back is round trip to the server for doing some task such as fetching the data from database based on user selection from combo box, adding data to database after pressing 'ADD' button on the server etc. Actually in upper part of the form I want to fetch the data based on user selection from combobox. After fetching the data, I want to write a report in text box based on the fetched data and then again want to save it database. Now in this case two post backs are required. 1.to fetch the data 2. To add new data. how can it be done? Quote Link to comment Share on other sites More sharing options...
ignace Posted May 12, 2010 Share Posted May 12, 2010 <form action="#" method="POST"> <input type="submit" name="submit"> </form> if (isset($_POST['submit'])) { echo "submit was pressed."; } Quote Link to comment Share on other sites More sharing options...
trq Posted May 12, 2010 Share Posted May 12, 2010 ignace's example is correct and simple, but it sounds to me more like you'd be looking to use ajax which is a combination of Javascript & some server side tech. With ajax you could make a request from the client to the server without refreshing the entire page. 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.