title: Redirect to a page/URL after alert button is pressed
body: <p>i have referred to this two questions <a href="https://stackoverflow.com/questions/7157029/call-php-page-under-javascript-function">call php page under Javascript function</a> and <a href="https://stackoverflow.com/questions/9394131/go-to-url-after-ok-button-in-alert-is-pressed">Go to URL after OK button in alert is pressed</a>. i want to redirect to my index.php after an alert box is called. my alert box is in my else statement. below is my code:</p>
  
  <p>processor.php</p>
  
  <pre><code>    if (!empty($name) &amp;&amp; !empty($email) &amp;&amp; !empty($office_id) &amp;&amp; !empty($title) &amp;&amp; !empty($var_title) &amp;&amp; !empty($var_story) &amp;&amp; !empty($var_task) &amp;&amp; !empty($var_power) &amp;&amp; !empty($var_solve) &amp;&amp; !empty($var_result)) {
  
      (some imagecreatefromjpeg code here)
  
      else{
          echo '&lt;script type="text/javascript"&gt;'; 
          echo 'alert("review your answer")'; 
          echo 'window.location= "index.php"';
          echo '&lt;/script&gt;';   
      }
  </code></pre>
  
  <p>it's not displ ying anything(no alert box and not redirecting). when i delet this part <code>echo 'window.location= "index.php"';</code> it's showing the alert. but still not redirecting to index.php. hope you can help me with this. please dont mark as duplicate as i have made tose posts as reference. thank you so much for your help.</p>