Skip to content
Advertisement

Redirect to Previous Page After Message

I want to go back to previous page after pressing “OK” on the function message prompted.

Php Code

function function_alert($message) { 
  
    // Display the alert box  
    echo "<script>alert('$message');
    document.location='javascript://history.go(-1)';
    </script>";
    } 

    // Function call 
    function_alert("This email has already subscribed");
 }

Alert Box

Thank you so much!

Advertisement

Answer

Tried this

function function_alert($message) { 
    echo "<script>
          alert('$message')
          history.back()
          </script>";
}
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement