插入messagebox java脚本

时间:2016-06-08 19:42:48

标签: php

我尝试使用脚本添加消息框。 当我点击按钮" registreren"时,会弹出消息框,但是当我按下取消时,代码仍然会更进一步并执行两次代码。

当按下OK按钮时,代码必须将记录添加到表中,当按下取消按钮时,代码应该停止并返回到预设页面。

<?php
if(isset($_POST['registreren'])) {

    session_start();

    $PartnerFName = mysqli_real_escape_string($con, $_POST['PartnerFName']);
    $PartnerLName = mysqli_real_escape_string($con, $_POST['PartnerLName']);

$ticket_id = $_GET['ticketID'];

$checkticketID = mysqli_query($con,"SELECT registratie.ticketID from registratie WHERE userID = ".$_SESSION['UserID'] ." AND ticketID = ".$_GET['ticketID'] ." ");

if (!$checkticketID) {
die('Query failed to execute for some reason');
}

if (mysqli_num_rows($checkticketID) > 0) {
?>
<script type="text/javascript">
   {
var r=confirm("U hebt deze registratie al eerder uigevoerd, toch verder gaan met de registratie?");
if (r==true){
//User Pressed okay. Verder gaan met de dubbele registratie
document.getElementById('myForm').submit();
    } 
    else
{
// user pressed cancel. Do nothing
 history.go(-1)
    }
}
        </script>
<?php

   $ticket = mysqli_fetch_array($checkticketID);
print_r($ticket); 
}

$sql = $con->query("INSERT INTO registratie(eventID, ticketID, UserID,     PartnerFName, PartnerLName)"
." SELECT eventID, ticketID, ".$_SESSION["UserID"].",'{$PartnerFName}','{$PartnerLName}' "
." FROM ticket WHERE ticketID = ".$_GET['ticketID'] ."") ;
    }       
?>

0 个答案:

没有答案