当用户更改输入时,如何在PHP中不断更新变量?

I looked for answers to this question, and it seems that most people have a specific problem. I'm looking for a more general answer. I have a text box where a user will type in their name and I would like to have PHP constantly monitor the text box and change the value of the $name as it is typed or edited.

I would also like to do the same with buttons, and as different buttons are clicked, the content of a variable would change to match that which the button represents. Basically, is there a way to get PHP to constantly run on the page and gather information from a user as it is changed?

It seems like it should be possible, but my experience with PHP is limited, and I'm not sure how to begin, so I don't have any code to really show.

This sounds to me like you require an ajax script checking for input changes(eg/ keystroke, on_blur or on_click for your buttons) and sending back to a php script that will update your variables/tables and return the new variables to the ajax script once they are updated.

1 - Ajax checking for changes on the page, and firing off to a php script on server.

2 - Have a method in your js that waits for the action to be completed and load the new variables into the HTML document.

Basically look up Ajax/PHP - Check username availability, Then adapt to your specific needs.

:)

Simple ajax script will be what your after, there are many scripts available for checking username availability --- As for a lone PHP script, this will not be possible as the PHP code has already ran on the server before the html document is rendered to the browser.

My first answer so my wording may not be perfect comment back if i have confused you more.

It seems like it should be possible, but my experience with PHP is limited, and I'm not sure how to begin, so I don't have any code to really show.

Yes, it's possible, but most likely only due to the nature that the browser (e.g. Firefox) and PHP itself are Free Software.

A proof of concept is missing so far, so you really need to start at a very basic level.

You can download these software packages and modify them to your needs, e.g. make the browser interactively corresponding to the DOM and DOM events process PHP scripts that you embed like script tags inside HTML.

But well, as you wrote, you're starting, so I guess, you don't want to start with rewriting the browser and the PHP interpreter, so even if possible, it's perhaps best to stick that interactive part inside the browser to Javascript and some HTTP request / response programming on the server with PHP.