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.
🌐
DaniWeb
daniweb.com › programming › web-development › threads › 265955 › echo-message-before-page-redirect
php - echo message before page redirect [SOLVED] | DaniWeb
use an html redirect so that you can specify how much time to allow before redirect. Just search google for html redirect and you can literally copy and paste. ... thanx.i did it using the html redirect code echo "<meta http-equiv='Refresh' ...
🌐
WebDeveloper.com
webdeveloper.com › community › 298129-how-to-display-message-before-redirect-to-other-page
How to display message before redirect to other page
@NogDogJul 16.2014 — #[code=php] header("refresh:5;url=Location :login.php"); // really should be a fully qualified URI echo '<script type="text/javascript">alert("Please Enter Correct Details!");</script>'; [/code] Note that header() must be executed before [i]anything[/i] gets output to the browser. ... php mail function - diffferent subject based on the recipientsNewbie: Alert Box from Class Methods?File Uploads Not Working from Some Systems ... about: ({ version: 0.1.9 — BETA 11.12, social: @webDeveloperHQ, }); legal: ({ terms: of use, privacy: policy analytics: Fullres }); ↴changelog: ( version: 0.1.9, notes: added community page version: 0.1.8, notes: added Davinci•003 version: 0.1.7, notes: upvote answers to bounties version: 0.1.6, notes: article editor refresh )...
🌐
Narkive
php-general.php.narkive.com › 8ByZVTSr › simple-alert-message-then-redirect
Simple Alert Message then Redirect?
-- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php ... Post by PartyPosters Hello I want to display an alert message then after users click ok I want to automatically goto a URL · 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 ;-).
🌐
Allwebdevhelp
allwebdevhelp.com › php › help-tutorials.php
PHP - How To Display Message Before Redirect To Other Page - AllWebDevHelp.com
PHP - How To Display Message Before Redirect To Other Page - Free PHP Programming Tutorials, Help, Tips, Tricks, and More.
Find elsewhere
🌐
Stack Overflow
stackoverflow.com › questions › 48702461 › how-to-display-an-alert-after-redirect-to-another-page
how to display an alert after redirect to another page
... Then in your config, or any ... do that in the template) do this: if(isset($_SESSION['alerts'])){ foreach($_SESSION['alerts'] as $alertmessage){ echo '<div class="alert">' ....
🌐
Appsloveworld
appsloveworld.com › php › 22 › display-message-before-redirect-to-other-page
Display message before redirect to other page
Working example in php. echo "<script>"; echo " alert('Import has successfully Done.'); window.location.href='".site_url('home')."'; </script>"; ... If you tell a browser by using a Location: header to redirect to another page, the browser does just this: It redirects to the other page.
🌐
CopyProgramming
copyprogramming.com › howto › javascript-alert-and-php-header
Php: Header redirection using PHP and triggering alerts with Javascript
June 6, 2023 - After conducting extensive research, I discovered a solution that involves delaying the alert message using a jQuery function. This delay enables the HTML page to load completely before the alert is executed. ... I am facing an issue with my PHP script. It works fine without a header, and I ...
🌐
PHP Freaks
forums.phpfreaks.com › php coding › php coding help
How to display message before redirect to other page - PHP Coding Help - PHP Freaks
July 16, 2014 - Hi, I'm trying to display a message first before redirect to other page, but my code just directly redirect the page without display the message.please help me. if($num_rows == 0) { echo ' '; header ('Locati...
🌐
Stack Overflow
stackoverflow.com › questions › 70159593 › how-to-show-alert-in-the-redirected-page
how to show alert in the redirected page?
On a index.php page, check if there’s a flash/alert message. If so, output and delete it. if (isset($_SESSION["alert"])) { echo "<div class='alert alert-success alert-dismissible'> <button type='button' class='close' data-dismiss='alert' aria-hidden='true'>&times;</button> <h4><i class='icon fa fa-check'></i> Alert!</h4> $_SESSION["alert"] </div>"; unset($_SESSION["flash"]); } ... While redirecting from delete.php/edit.php to index.php you can pass some query params.