我希望在数据库中插入数据后显示sweetalert

时间:2017-02-27 05:20:54

标签: javascript php mysql

这是我在mysql中插入数据并在插入后显示sweetalert的php代码,但不显示sweetalert。

<?php  
        if(isset($_POST['submit']))
        {
            $fullname=$_POST['txtFullName'];
            $email=$_POST['txtEmailId'];
            $contact=$_POST['txtContactNumber'];
            $msg=$_POST['txtMessage'];
            if($fullname!="" && $email!="" && $contact!="" && $contact!="")
            {
            $qry=mysql_query("insert into Contacts values('0','$fullname','$email','$contact','$msg')");
            mysql_query($qry) or die(mysql_error());    
            echo '<script type="text/javascript">
            myFn();
            </script>';
            }
        }
    ?>

这是我插入数据的模型:

    <div id="fancy">
        <h2>Request information</h2>
        <form action="index.php" method="post" enctype="multipart/form-data" name="frmContact" id="frmContact">
            <input type="hidden" name="hdid" id="hdid" value="<?php echo isset($row["ContactId"])?$row["ContactId"]:"" ?>" />
            <div class="left">
                <fieldset class="name"><input placeholder="Full Name..." required="required" type="text" name="txtFullName" id="txtFullName"></fieldset>
                <fieldset class="mail"><input placeholder="Email address..." required="required" type="text" name="txtEmailId" id="txtEmailId"></fieldset>
                <fieldset class="name"><input placeholder="Contact Number" required="required" type="text" name="txtContactNumber" id="txtContactNumber"></fieldset>
            </div>
            <div class="right">
                <fieldset class="question"><textarea placeholder="Your Message..." required="required" name="txtMessage" id="txtMessage"></textarea></fieldset>
            </div>
            <div class="btn-holder">

                <button class="btn blue" type="submit" id="submit" name="submit">Send request</button>
            </div>
        </form>
    </div>

这是我的函数myFn

<script type="text/javascript">


    function myFn(){
        swal({ 
              title: "Success",
              text: "Thank you for contacting us. We will get back to you soon!",
              type: "success" 
        },
             function(){
                //event to perform on click of ok button of sweetalert
        });
    }

</script>

请帮我解决这个问题

0 个答案:

没有答案