0

I am creating form using html and php,after submission of form i want to display success message with sweetalert and want to locate window to another page.I tried following code but but it is not working.Please tell me where i am going wrong

echo '<script type="text/javascript">';
echo 'setTimeout(function () {';
echo 'swal("Success!","Your complaint has been successfully registered.\n Your Customer Complaint No. is\n  "+"'.$complainno.'","success")
    .then( function(val) {  if (result.value) {
        window.location = "/cashier.php";
    }';             
echo '});';
echo '}, 200);  </script>';
Qirel
  • 25,449
  • 7
  • 45
  • 62
Snehal
  • 21
  • 6

1 Answers1

0

Here is the solution :

echo '<script>
        setTimeout(function() {
            swal({
                title: "Success!",
                text: "Your complaint has been successfully registered.Your Customer Complaint No. is"+$complainno,
                type: "success"
            }, function() {
                window.location.href = "cashier.php"; // window.location also can be used
            });
    }, 1000);
</script>';
PHP Ninja
  • 1,055
  • 2
  • 9
  • 28