Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8662041
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T16:38:26+00:00 2026-06-12T16:38:26+00:00

I met a trouble with a script I have done. Here is the entire

  • 0

I met a trouble with a script I have done.

Here is the entire script. But the trouble concern only 2 lines.

In fact I have a PHP condition if it is respected it should display an alert if not, it should execute the following script.

and at the end I have a header location that makes the user go back to the previous page.

The thing is that it does not display the alert, it directly make the user go back. I would like to make the user click on ‘ok’ in order to make the script continue. Is there a way I can do that.?

<?php
$sql="SELECT SUM(montant) as montantfactures, n_doss
      FROM  `factures` 
      WHERE `n_doss`='".mysql_real_escape_string($_GET['n_doss'])."'
      GROUP BY `n_doss`";

$result=mysql_query($sql) or die;
while($data=mysql_fetch_assoc($result))
{
    $rqt="SELECT `interets`.*,
                 `les_taux`.*,
                 `decompte`.`principal_s`
          FROM   `interets`
          INNER JOIN `les_taux` ON `interets`.`type`=`les_taux`.`type`
          INNER JOIN `decompte` ON `interets`.`n_doss`=`decompte`.`n_doss`
          WHERE `interets`.`n_doss`='".$data['n_doss']."' 
          GROUP BY `date_modif` DESC
          LIMIT 1";
    $resultat=mysql_query($rqt) or die;
    $donnees=mysql_fetch_assoc($resultat);

    {$datefin=$donnees['date_fin'];}
    $datedepart=$donnees['date_depart'];
    if($donnees['date_fin']==date('Y-m-d'))
    {
        echo "<script type=\"text/javascript\">alert(\"les interets sont deja a jour\")</script>";
    }
    else
    {
        if($donnees['type']=='tc')
        {

            if($donnees['montant']==0)
            {

                $taux=($donnees['valeur']*1);
                $nbjours=round((strtotime($datefin) - strtotime($datedepart))/(60*60*24)-1);
                $interets=(($data['montantfactures']-$donnees['principal_s'])*$nbjours*$taux)/(365*100);
                $nouveauinterets=$donnees['montant']+$interets ;
                $itc="UPDATE `interets` SET
                    montant     =   '".$nouveauinterets."',
                    date_fin= NOW() WHERE n_doss='".$donnees['n_doss']."'
                    ";
                $rtq    =   mysql_query($itc) or die(__LINE__.mysql_error().$itc);
                echo "<img src='images/tick_48.png' width='24'> Int&eacute;r&ecirc;ts correctement mis &agrave; jour pour le dossier n&deg;".$donnees['n_doss'].'<br>' ;


            }

            else
            {

                $taux=($donnees['valeur']*1);
                $nbjours=round((strtotime($datefin) - strtotime($datedepart))/(60*60*24)-1);
                $interets=(($data['montantfactures']-$donnees['principal_s'])*1*$taux)/(365*100);
                $nouveauinterets=$donnees['montant']+$interets ;
                $itc="UPDATE `interets` SET
                    montant     =   '".$nouveauinterets."',
                    date_fin= NOW() WHERE n_doss='".$donnees['n_doss']."'";
                $rtq    =   mysql_query($itc) or die(__LINE__.mysql_error().$itc);
                echo "<img src='images/tick_48.png' width='24'> Int&eacute;r&ecirc;ts correctement mis &agrave; jour pour le dossier n&deg;".$donnees['n_doss'].'<br>' ;

            }
        }
        elseif($donnees['type']=='tleg')
        {

            if($donnees['montant']==0)
            {
                if($donnees['operateur']=="x")
                {
                    $taux=($donnees['valeur']*$donnees['variable']);
                    $nbjours=round((strtotime($datefin) - strtotime($datedepart))/(60*60*24)-1);
                    $interets=(($data['montantfactures']-$donnees['principal_s'])*$nbjours*$taux)/(365*100);
                    $nouveauinterets=$donnees['montant']+$interets ;
                    $itc="UPDATE `interets` SET
                    montant     =   '".$nouveauinterets."',
                    date_fin= NOW() WHERE n_doss='".$donnees['n_doss']."'";
                    $rtq    =   mysql_query($itc) or die(__LINE__.mysql_error().$itc);
                    echo "<img src='images/tick_48.png' width='24'> Int&eacute;r&ecirc;ts correctement mis &agrave; jour pour le dossier n&deg;".$donnees['n_doss'].'<br>' ;
                }
                elseif($donnees['operateur']=="+")
                {
                    $taux=($donnees['valeur']+$donnees['variable']);
                    $nbjours=round((strtotime($datefin) - strtotime($datedepart))/(60*60*24)-1);
                    $interets=(($data['montantfactures']-$donnees['principal_s'])*$nbjours*$taux)/(365*100);
                    $nouveauinterets=$donnees['montant']+$interets ;
                    $itc="UPDATE `interets` SET
                    montant     =   '".$nouveauinterets."',
                    date_fin= NOW() WHERE n_doss='".$donnees['n_doss']."'";
                    $rtq    =   mysql_query($itc) or die(__LINE__.mysql_error().$itc);
                    echo "<img src='images/tick_48.png' width='24'> Int&eacute;r&ecirc;ts correctement mis &agrave; jour pour le dossier n&deg;".$donnees['n_doss'].'<br>' ;
                }
            }
            else
            {
                if($donnees['operateur']=="x")
                {
                    $taux=($donnees['valeur']*$donnees['variable']);
                    $nbjours=round((strtotime($datefin) - strtotime($datedepart))/(60*60*24)-1);
                    $interets=(($data['montantfactures']-$donnees['principal_s'])*1*$taux)/(365*100);
                    $nouveauinterets=$donnees['montant']+$interets ;
                    $itc="UPDATE `interets` SET
                    montant     =   '".$nouveauinterets."',
                    date_fin= NOW() WHERE n_doss='".$donnees['n_doss']."'";
                    $rtq    =   mysql_query($itc) or die(__LINE__.mysql_error().$itc);
                    echo "<img src='images/tick_48.png' width='24'> Int&eacute;r&ecirc;ts correctement mis &agrave; jour pour le dossier n&deg;".$donnees['n_doss'].'<br>' ;
                }
                elseif($donnees['operateur']=="+")
                {
                    $taux=($donnees['valeur']+$donnees['variable']);
                    $nbjours=round((strtotime($datefin) - strtotime($datedepart))/(60*60*24)-1);
                    $interets=(($data['montantfactures']-$donnees['principal_s'])*1*$taux)/(365*100);
                    $nouveauinterets=$donnees['montant']+$interets ;
                    $itc="UPDATE `interets` SET
                    montant     =   '".$nouveauinterets."',
                    date_fin= NOW() WHERE n_doss='".$donnees['n_doss']."'";
                    $rtq    =   mysql_query($itc) or die(__LINE__.mysql_error().$itc);
                    echo "<img src='images/tick_48.png' width='24'> Int&eacute;r&ecirc;ts correctement mis &agrave; jour pour le dossier n&deg;".$donnees['n_doss'].'<br>' ;

                }
            }
        }
        elseif($donnees['type']=='tbce')
        {

            if($data['montantfactures']==0)
            {
                if($donnees['operateur']=="x")
                {
                    $taux=($donnees['valeur']*$donnees['variable']);
                    $nbjours=round((strtotime($datefin) - strtotime($datedepart))/(60*60*24)-1);
                    $interets=(($data['montantfactures']-$donnees['principal_s'])*$nbjours*$taux)/(365*100);
                    $nouveauinterets=$donnees['montant']+$interets ;
                    $itc="UPDATE `interets` SET
                    montant     =   '".$nouveauinterets."',
                    date_fin= NOW() WHERE n_doss='".$donnees['n_doss']."'";
                    $rtq    =   mysql_query($itc) or die(__LINE__.mysql_error().$itc);
                    echo "<img src='images/tick_48.png' width='24'> Int&eacute;r&ecirc;ts correctement mis &agrave; jour pour le dossier n&deg;".$donnees['n_doss'].'<br>' ;
                }
                elseif($donnees['operateur']=="+")
                {
                    $taux=($donnees['valeur']+$donnees['variable']);
                    $nbjours=round((strtotime($datefin) - strtotime($datedepart))/(60*60*24)-1);
                    $interets=(($data['montantfactures']-$donnees['principal_s'])*$nbjours*$taux)/(365*100);
                    $nouveauinterets=$donnees['montant']+$interets ;
                    $itc="UPDATE `interets` SET
                    montant     =   '".$nouveauinterets."',
                    date_fin= NOW() WHERE n_doss='".$donnees['n_doss']."'";
                    $rtq    =   mysql_query($itc) or die(__LINE__.mysql_error().$itc);
                    echo "<img src='images/tick_48.png' width='24'> Int&eacute;r&ecirc;ts correctement mis &agrave; jour pour le dossier n&deg;".$donnees['n_doss'].'<br>' ;
                }
            }
            else
            {

                if($donnees['operateur']=="x")
                {
                    $taux=($donnees['valeur']*$donnees['variable']);
                    $nbjours=round((strtotime($datefin) - strtotime($datedepart))/(60*60*24)-1);
                    $interets=(($data['montantfactures']-$donnees['principal_s'])*1*$taux)/(365*100);
                    $nouveauinterets=$donnees['montant']+$interets ;
                    $itc="UPDATE `interets` SET
                    montant     =   '".$nouveauinterets."',
                    date_fin= NOW() WHERE n_doss='".$donnees['n_doss']."'";
                    $rtq    =   mysql_query($itc) or die(__LINE__.mysql_error().$itc);
                    echo "<img src='images/tick_48.png' width='24'> Int&eacute;r&ecirc;ts correctement mis &agrave; jour pour le dossier n&deg;".$donnees['n_doss'].'<br>' ;
                }
                elseif($donnees['operateur']=="+")
                {
                    $taux=($donnees['valeur']+$donnees['variable']);
                    $nbjours=round((strtotime($datefin) - strtotime($datedepart))/(60*60*24)-1);
                    $interets=(($data['montantfactures']-$donnees['principal_s'])*1*$taux)/(365*100);
                    $nouveauinterets=$donnees['montant']+$interets ;
                    $itc="UPDATE `interets` SET
                    montant     =   '".$nouveauinterets."',
                    date_fin= NOW() WHERE n_doss='".$donnees['n_doss']."'";
                    $rtq    =   mysql_query($itc) or die(__LINE__.mysql_error().$itc);
                    echo "<img src='images/tick_48.png' width='24'> Int&eacute;r&ecirc;ts correctement mis &agrave; jour pour le dossier n&deg;".$donnees['n_doss'].'<br>' ;
                }
            }
        }
    }
}
header('Location: ' . $_SERVER['HTTP_REFERER'] );
?>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T16:38:27+00:00Added an answer on June 12, 2026 at 4:38 pm

    Javascript can’t stop php execution! javascript runs on the client side (browser) and php runs in the server. if you write header(‘Location: ‘ . $_SERVER[‘HTTP_REFERER’] ); , it will always redirect you there.

    If I was you, I would modify this line and add this:

    echo "<script type=\"text/javascript\">alert(\"les interets sont deja a jour\"); window.location = $_SERVER['HTTP_REFERER']
    </script>"; 
    

    and remove the header location, of course..

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I met trouble with a script I have done, this script should allocate an
I met a trouble with a form. In fact I have a php dynbamic
I'm having trouble inserting a block of text when a certain condition is met
I met some trouble in php json decode number. $json = '[{num:123456789011121314},{num:1516171819202122232425}]'; $number =
I met some basic problem in jquery, but I can't figure it out. Here
I asked a question earlier but met harsh criticism, so here I pose it
I have met a problem with virtualbox, I hope someone could help me here,
I met strange problem. I have never work with Devise gem before. So, i
i met a very strange PHP behaviour, i don't understand why it behaves like
I've been working on a dynamic question-and-answers system, but I'm having trouble creating a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.