使用PHP触发Bootstrap模式

时间:2015-04-23 11:05:28

标签: javascript php twitter-bootstrap-3

我需要在成功提交Bootstrap表单后触发Bootstrap模式。我试过使用javascript行,但不知道如何从PHP触发模式?

<?php
    $title = $_POST['title'];
    $fname = $_POST['fname'];
    $surname = $_POST['surname'];
    $contactno = $_POST['contactno'];
    $email = $_POST['email'];
    $roomno = $_POST['roomno'];
    $address = $_POST['address'];
    $town = $_POST['town'];
    $county = $_POST['county'];
    $postcode = $_POST['postcode'];
    $floorplan = $_POST['floorplan'];
    $from = 'sentMessage'; 
    $to = 'example.com'; 
    $subject = 'Quote Request';
    $body ="From: $title\n fname : $surname\n conatctno : $email\n roomno : $address\n town : $county\n postcode : \n $floorplan";

// If there are no errors, send the email

    if (mail ($to, $subject, $body, $from)){
        setcookie("success","success", time() +100, "/" );
        header('location: index.php');

    }else{
        setcookie("error","error", time() +100, "/" );
        header('location: index.php');
    };

?>      

1 个答案:

答案 0 :(得分:0)

将值传递给视图,例如

$msg = true;

什么时候想要发射模态。 检查变量是否已在javascript中设置:

var msg = "<?php echo $msg ?>";
if(msg == "1") {
  // fire here the modal,  like
  $('#hidden-modal-handle').click();
  // where hidden-modal-handle in this case is the id       of the anchor tag that fires the modal
}

将js代码放在$(document).ready function