I use a custom alert javascript. I want to call this javascript inside a php. I got a basic alert to work but I cannot get the custom one to work.
This code works. It opens an alert window if my file path is empty
<?php
$albums_json_file1 = site_path . DIRECTORY_SEPARATOR . 'users' . DIRECTORY_SEPARATOR . $username . DIRECTORY_SEPARATOR . 'main.json';
if (!empty($albums_json_file1))
echo "<script type='text/javascript'>alert('message')</script>"
?>
This code does not work
<?php
$albums_json_file1 = site_path . DIRECTORY_SEPARATOR . 'users' . DIRECTORY_SEPARATOR . $username . DIRECTORY_SEPARATOR . 'main.json';
if (!empty($albums_json_file1))
echo "<script> swal('REGISTRATION SUCCESS!', 'You are now being redirected to the payment screen!', 'success'); </script>"
?>
In my webpage I have the script source for the custom alert and if I just add this code in my webpage the popup alert works BUT I need it to check the site path and return the alert only if it is empty.
Here is the regular script. If I put this in the body of my webpage the alert pops up.
<script>
swal("REGISTRATION SUCCESS!", "You are now being redirected to the payment screen!", "success");
</script>