1
echo "`<script>` alert('Profile already Exist for this ip'); `</script>`";
header("location:backupprofile_windowstonas_step2.php");
die("123");

I have above code in which I am show message to my user that profile already exist for this ip it work fine but then go to other page is not working with header function. It directly go to die function and echo 123. What is the reason behind this?

Thamilhan
  • 13,040
  • 5
  • 37
  • 59
LOKESH
  • 1,303
  • 1
  • 16
  • 29

1 Answers1

1

You could try like this:

echo "<script>alert('Profile already Exist for this ip');</script>";
echo "<script>location.href='backupprofile_windowstonas_step2.php'</script>";
Thamilhan
  • 13,040
  • 5
  • 37
  • 59
  • why php header not work I want to know this reason – LOKESH Nov 02 '15 at 06:07
  • 1
    @LOKESH, look at my comment and you will know why, you are outpitting a valie "the alert" in your case, before using header(), header function should be used without any output before it, not even a whitespace – Mi-Creativity Nov 02 '15 at 06:11
  • also read the already answered stackoverflow question posted by Sougata http://stackoverflow.com/questions/8028957/how-to-fix-headers-already-sent-error-in-php – Mi-Creativity Nov 02 '15 at 06:12