title: How to change the inner content of a new page from the function called at the previous page?
body: <p>I am learning PHP and JS and trying to create a log in page using PHP,MySQL and JS.
  Here, I am trying to check whether the login details are correct or not. if it's correct then it will redirect the user to index.php and show a message on the top Logged in Successfully.
  So, On clicking on submit button PHP is going to check whether it matches the detail or not from the MySQL database, If yes then it will call a JS function which is going to redirect the user to index.php and change the inner HTML just below the header and show the message, but the problem is instead of showing the message at index.php it is showing the message at the same log-in page and before even someone sees the message the page immediately redirects to index.php.
  I want that message to be shown at index.php and not at login.php. How do I do that?</p>
  <p>PHP: If MySQLI Query return some result or not</p>
  <pre><code>if($count == 0){
      echo &quot;&lt;script&gt; email('n'); &lt;/script&gt;&quot;; 
  } else {
      echo &quot;&lt;script&gt; email('y'); &lt;/script&gt;&quot;;
  </code></pre>
  <p>JavaScript Function: If it receives Yes or no from PHP</p>
  <pre><code>function email(status) {
  if (status == &quot;y&quot;) {
      document.getElementById(&quot;alert&quot;).innerHTML =
          &quot;&lt;p class='success'&gt; Access Granted &lt;/p&gt;&quot;
  }
  else {
      document.getElementById(&quot;alert&quot;).innerHTML =
          &quot;&lt;p class='failed'&gt; Access Denied &lt;/p&gt;&quot;
  }
  };
  </code></pre>
  <p>HTML: The header is common for all the pages in the site and there is an external css attached to it.</p>
  <pre><code>&lt;div id=&quot;alert&quot;&gt;
  &lt;/div&gt;
  </code></pre>
  <p>This is an empty div tag which is going to be changed if js function is called to change it's innerHTML.
  Please guide me.</p>