javascript - Confirm only does else part of the code -


so script below reason else part of code no matter if confirm during prompt. update whole function leads confirmation prompt without confirm function header('refresh: 0; url=new_items.php?patch_no='.$patch.''); works supposed to.

     public function save_champions($champion, $noofspellschamp, $patch, $champ_number, $champnospellno, $spellicon, $spelltitle, $change, $description){                 include '../dbconnection_patches.php';                  $sql ='';                 $sql ="insert info (patch_no)                         values ('".$patch."')";                 $conn->query($sql);                 for($i = 1; $i<=$champ_number; $i++){                     $sql =                      "insert champions (patch_no, champion)                     values (                         '".$patch."',                         '".$champion[$i]."'                     )";                     $conn->query($sql);                      for($j=1; $j<=$noofspellschamp[$i]; $j++){                         switch($spellicon[$i][$j]){                             case 'passive':                             $sql = "update champions set passive='".$spelltitle[$i][$j]."' champion='".$champion[$i]."' , patch_no='".$patch."'";                             $conn->query($sql);                             break;                             case 'q':                             $sql = "update champions set q='".$spelltitle[$i][$j]."' champion='".$champion[$i]."' , patch_no='".$patch."'";                             $conn->query($sql);                             break;                             case 'w':                             $sql = "update champions set w='".$spelltitle[$i][$j]."' champion='".$champion[$i]."' , patch_no='".$patch."'";                             $conn->query($sql);                             break;                             case 'e':                             $sql = "update champions set e='".$spelltitle[$i][$j]."' champion='".$champion[$i]."' , patch_no='".$patch."'";                             $conn->query($sql);                             break;                             case 'r':                             $sql = "update champions set r='".$spelltitle[$i][$j]."' champion='".$champion[$i]."' , patch_no='".$patch."'";                             $conn->query($sql);                             break;                         }                         for($k=1;$k<=$champnospellno[$i][$j];$k++){                                 $sql = "insert spells (patch_no, champion, spell_change, spell_change_icon, spell_type)                                 values(                                 '".$patch."',                                 '".$champion[$i]."',                                  '".$description[$i][$j][$k]."',                                 '".$change[$i][$j][$k]."',                                 '".$spellicon[$i][$j]."'                                 )";                                 $conn->query($sql);                         }                     }                 }                  echo $conn->error;                 if(empty($conn->error)){                     echo '<script>                      if (confirm("champions saved. wish create items page?")== true) {                         ';                         header('refresh: 0; url=new_items.php?patch_no='.$patch.'');                     echo '} else {';                         header('refresh: 0; url=../index.php');                     echo '}                     </script>';                     exit;                     //                  }             } 

the problem you're trying mix php , javascript code. if want redirect based on user input, should whole redirection in javascript. in php you're writing header telling page redirect, telling redirect different page.

if(empty($conn->error)){     echo "<script>         if (confirm(\"champions saved. wish create items page?\")) {             window.location = \"new_items.php?patch_no=$patch\";         } else {             window.location = \"../index.php\";         }     </script>";     exit; } 

Comments

Popular posts from this blog

node.js - Using Node without global install -

How to access a php class file from PHPFox framework into javascript code written in simple HTML file? -

java - Null response to php query in android, even though php works properly -