I want to run a php script each time the input value of the <input type="text">
changes, for like checking if the passwords in a registration form are the same
PHP is server side scripting language, so when you submit the form then it will check the value of both textboxes..
Instead of PHP you can use JavaScript or jQuery or AJAX to check the value of both text box.
PHP is a server side language, and its work is finish once the processing completes and the HTML is thrown out to the browser. It can only only responds to user actions if a new server side request is generated for every user inout.
Where as javascript is the client side language, which can interact with the user and server both.
Now if you want to hit on the server, on every user input in the text box, then you have to do it using javascript, which indirectly send a ajax call to the server to get its response, and to do the required changes.
Another good option (especially if you do your processing on the same page) would be to simply check the field when the user submits it.
If it meets the required standards let it pass, otherwise just repopulate the fields with the data that was submitted, and produce some error text next to the field(s) that need it.
Its not as "pretty" as an AJAX solution, but its almost as convenient and is very easy to do in PHP.
<form method="POST" onsubmit="return check()">
<input type="password" name="pass" id="pass" onchange="check(this)>
<input type="password" name="pass1" id="pass1" onchange="check(this)>
</form>
and than javascript
function check()
{
var pass = document.getElementById('pass').value;
var pass1 = document.getElementById('pass1').value;
if(pass1 != pass)
{
alert("Pass don't macth");
return false;
}
}
maybe something like that?