I would like to update the value of the first user with the second user without reloading, using HTML and PHP.
user.html
<html>
<head>
</head>
<h1>color</h1>
<body>
<div id="txtHint">
<form name="myForm" action="color.php" method="get">
<tr><td>color<input type='text' name='color' id='clr/></td></tr>
<tr><td><input type='submit' id='submit' name='submit' onclick=''/></td></tr>
</form>
</div>
</body>
</html>
color.php
<?php
$color=$_GET['color'];
?>
For example, user types "red" and therefore displays "red" in the PHP page:
user2.html
<html>
<head>
</head>
<h1>color</h1>
<body>
<div id="txtHint">
<form name="myForm" action="color.php" method="get">
<tr><td>color<input type='text' name='color' id='clr'/></td></tr>
<tr><td><input type='submit' id='submit' name='submit' onclick=''/></td></tr>
</form>
</div>
</body>
</html>
I want the output such that once user 2 types any color, the color of user 1 also gets changed to the user2 color. How can I do that?
You will need ajax to do this.
Only echo in php page can do nothing. You need to save the color to a database.
In the user.html page you should check periodically for changes in the database. And in the user2.html page you need to update the database using ajax or do a normal post or get method.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.