echo "<script>
alert('There are no fields to generate a report');
window.location.href='admin/ahm/panel';
</script>";

and get rid of redirect line below.

You were mixing up two different worlds.

Answer from Prasanth on Stack Overflow
🌐
GitHub
gist.github.com › ErMandeep › 6faea4751b7f388c94651dd811933dc0
display alert message after redirecting page php · GitHub
display alert message after redirecting page php. GitHub Gist: instantly share code, notes, and snippets.
🌐
Talkerscode
talkerscode.com › howto › alert-in-php-and-redirect.php
Alert In PHP And Redirect
In which <?php is our opening tag and ?> is our closing tag. Here, as we see that to alert a message we use alert() function with the help of jQuery. In first case, we use script inside echo and then alert inside that. In next method, we create a function with alert and call it later with required parameter. Now, for redirection here are again two methods.
🌐
Narkive
php-general.php.narkive.com › 8ByZVTSr › simple-alert-message-then-redirect
Simple Alert Message then Redirect?
Post by PartyPosters if ($var_stock_count == 0){ alert("Message") redirect("http://www.google.co.uk"); } <script language='JavaScript'> alert("Message"); window.location = "http://www.google.com"; </script> should do the work ;-). Hope this helps, -- Josip Dzolonga http://josip.dotgeek.org jdzolonga[at]gmail.com · -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
🌐
Bytes
bytes.com › home › forum › topic › php
php javascript alert redirect - Post.Byes
so if this is true then alert should popup first before the PHP Header redirect. you're mixing up server code and browser code. first, all of the server code is executed (i.e the redirect via header()), afterwards, all browser code is executed (i.e.
🌐
X
freeonlineprojects.com › alert-message-and-page-redirect-not-working-inside-php
Alert Message and Page Redirect Not Working Inside PHP
JavaScript is not available · We’ve detected that JavaScript is disabled in this browser. Please enable JavaScript or switch to a supported browser to continue using x.com. You can see a list of supported browsers in our Help Center · Help Center · Terms of Service Privacy Policy Cookie ...
Find elsewhere
🌐
SitePoint
sitepoint.com › php
Php - alert box - PHP - SitePoint Forums | Web Development & Design Community
December 3, 2010 - Hi, I’ve looking for this on the web and haven’t found a clear explanation for my question. I have 2 pages, user select a story on the first page. Second page (using post method) receives the story value(there are only 3 options) and does something. If a user opens the second page without choosing a story, I want to pop an alert box saying user needs to choose a story first and redirect user to the first page. here is my php code $story = $_POST["stories"]; if (($story!= "story1.txt") && ...
🌐
Asprunner
asprunner.com › forums › topic › 24982-redirect-page-and-alerts
redirect page and alerts
hi, i'd like to redirect to another page after record added with a condition. I try with this code in ater record added: echo "<script>alert('ATTENTION1: Value of apridistinta is : ".$_REQUEST["apridistinta"] ."')</script>"; if ($_REQUEST["apridistinta"]=='S') { if (!$inline){ if ...
🌐
SitePoint
sitepoint.com › php
Printing confirmation message after redirect - PHP - SitePoint Forums | Web Development & Design Community
April 13, 2020 - Please house, i have spent hours on this without success. I have a form that i did redirected to a query after submission, and i passed some variables to session so that i can echo it once we get to the confirmation page It works and prints the confirmation message.
🌐
WebDeveloper.com
webdeveloper.com › community › 217839-how-do-i-add-a-msg-box-alert-before-changing-header
How do i?.. Add a msg box alert before changing header.
Without delving into AJAX, your options are to send the popup after the javascript validation and then let PHP do the redirect, or else output some javascript from your PHP script which shows the popup and then redirects.
🌐
Itecnote
itecnote.com › tecnote › php-display-alert-message-and-redirect-after-click-on-accept
Display alert message and redirect after click on accept
Skip to content · React-native – React Native Error: “Animated.event now requires a second argument for options” · Python – keep on getting “x and y must have same first dimension, but have shapes (100,) and (1, 100)” · Java – Docker WARNING: Published ports are discarded when ...