0

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?

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.