|
I may be misjudging things, but I don't think you understand the nature of the normal http interaction. It is not a continuous connection between the client and the server. It is not interactive, as is a phone call, but a request/response transaction, more like a radio. The client makes a request, the server responds. The request is usually for a resource like a page. The client, if it receives the resource, will render it.
Your code does not represent an instantaneous reaction where the HTML is client talk and the PHP is server talk. The entire thing is server preparation of a page. The server is forming a page description with the HTML. The PHP is operating things on the server, and may be actively generating some HTML. When the entire page is complete, at the end of your script, then it is sent to the client for rendering and limited action (in the absence of client-side script). The action may be field modification and submission of the form. That forms a NEW request. The server analyzes that request and responds appropriately, WITH A NEW PAGE.
I did not put update features on my example. The idea was to begin simply. To add update features, you would change the field on the form so that you could indicate to the server, via a form field (post information) or a query variable (get information) that you wished the contents of the form to represent an update to existing information. A good idea would be to include the PersonID in the form. If the PersonID existed in the DB, the information would be changed with an update command. If it did not exist, it would be added with an insert command. The DB would then be queried, a new page prepared (with the complete information), and sent to the client as a response.
I think you need to sit down and think about this, organize your approach, create your design, and code and test it.
Let me reemphasize that PHP code in the middle of HTML code does not represent an interaction with the client. It is strictly page preparation on the fly.
If I am mistaken in my guess, my apologies.
|