-1

I want to set a button that when I click on that it goes to another page.

below is my code:

if(sizeof($errors) > 0)
     {
       foreach($errors as $err)
       {
         echo "<script type='text/javascript'>alert('$err');</script>";
       }
     }
     else
     {
       echo "<script type='text/javascript'>alert('finish');</script>";
       $newURL = "additional_info_sodur_card?id=" + $_GET['id'];
       header('Location: $newURL');

     }

Everything is OK and even to assure that it enters the else part I have written an alert which works. The problem is that for header part it gives me an error like this: Cannot modify header information - headers already sent by ... how can I solve this problem? Can I use javascript with windows.location.href or other ways to be redirected to another page? thanks for your response in advance

1 Answers1

0

I prefer to use JS redirect instead to avoid this.

?>
  <script language="javascript" type="text/javascript">
    alert('Your alert.');

    window.location = 'redirect_url';
  </script>
<?php

Hope this helps.