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.
Discussions

Redirect to a page/URL after alert button is pressed
i have referred to this two questions call php page under Javascript function and Go to URL after OK button in alert is pressed. i want to redirect to my index.php after an alert box is called. my ... More on stackoverflow.com
🌐 stackoverflow.com
November 7, 2013
header - PHP: give alert popup then redirect the page - Stack Overflow
The problem is that header("location:index.php"); sets the response code to 302 automatically. The browser immediately redirects without looking at the contents of the page. You need to either do the redirect itself in javascript after the alert is sent, or else have the page you're redirecting ... More on stackoverflow.com
🌐 stackoverflow.com
Php - alert box - PHP - SitePoint Forums | Web Development & Design Community
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 ... More on sitepoint.com
🌐 sitepoint.com
0
December 3, 2010
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 ""; if ($_REQUEST["apridistinta"]=='S') { if (!$inline){ if ... More on asprunner.com
🌐 asprunner.com
🌐
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
August 7, 2009 - 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.
Find elsewhere
🌐
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 ...
🌐
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 8, 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.
🌐
Stack Overflow
stackoverflow.com › questions › 39901426 › redirection-and-showing-alerts-using-javascript
php - Redirection and showing alerts using Javascript - Stack Overflow
September 7, 2020 - The data update and redirection are working. The alert message is not being displayed. I am aware that I have sql injection issue. I will work on it after I have the alert working. <!DOCTYPE html> <?php ob_start(); ?> <html> <head> <title>Multiple Update and Delete Data</title> <?php include "header.php"; ?> </head> <body bgcolor="#DCE3E7"> <script type="text/javascript"> function confirm() { if (window.confirm('Are you sure you want to update these properties?')) { window.alert("Successfully update."); document.location.href ='list_sale_update.php'; return true; } else { alert("Error editing list.
🌐
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 ...