Prevent page load after javascript confirm dialog -


on results portion of employee registration page, need check duplicates prior completing registration. so, variables posted results page , query database 3 different ways find similarities:

1st case: if same ssn, show confirm box either redirects existing chart if ok clicked or redirects registration "try again" if cancel clicked.

2nd , 3rd case: if registrant has last name or first name plus same date of birth of in database, choice given - ok redirects list of persons or cancel continue results page , register new employee.

the 1st case works fine because in either case redirecting away results page. second , third cases though, if ok clicked, page redirected not before completing registration - don't want happen.

here's code:

/*primary check*/ $sql_personnel_check = mysqli_query($globals["___mysqli_ston"], 'select * personnel ssn = "'.$ssn.'"'); $count = mysqli_num_rows($sql_personnel_check); if ($count > 0) {     $row_personnel_check = mysqli_fetch_array($sql_personnel_check); ?>     <script type='text/javascript'>     if (confirm('based on social security number entered, record candidate exists.  please click ok view record.  click cancel go , re-enter details.')) {                         window.location.href='rainmaker.php?eid=<?php echo $row_personnel_check['eid']; ?>';                     }                     else {                         history.go(-1);                     }                 </script>          <?php                 exit;                }             /*secondary check*/             $sql_personnel_check_2 = mysqli_query($globals["___mysqli_ston"], 'select * personnel lname = "'.$lname.'" , dob = "'.$dob.'"');             $count_2 = mysqli_num_rows($sql_personnel_check_2);             if ($count_2 > 0) {                 $row_personnel_check_2 = mysqli_fetch_array($sql_personnel_check_2);         ?>                 <script type='text/javascript'>                     if (confirm('based on last name , date of birth combination entered, record employee may exist.    click ok view possible matche(s).  click cancel create new record.')) {                         document.location.href='personnel_report.php?dob=<?php echo $row_personnel_check_2['dob']; ?>&lname=<?php echo $row_personnel_check_2['lname']; ?>';                      }                     else {                      }                 </script>         <?php              }             /*tertiary check*/             $sql_personnel_check_3 = mysqli_query($globals["___mysqli_ston"], 'select * personnel fname = "'.$fname.'" , dob = "'.$dob.'"');             $count_3 = mysqli_num_rows($sql_personnel_check_3);             if ($count_3 > 0) {                 $row_personnel_check_3 = mysqli_fetch_array($sql_personnel_check_3);         ?>                 <script type='text/javascript'>                     if (confirm('based on first name , date of birth combination entered, record employee may exist.   click ok view possible matche(s).  click cancel create new record.')) {                         document.location.href='personnel_report.php?dob=<?php echo $row_personnel_check_3['dob']; ?>&fname=<?php echo $row_personnel_check_3['fname']; ?>';                     }                     else {                      }                 </script>         <?php               } ?> 


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -