簡體   English   中英

如何將windows.alert替換為sweetalert?

[英]How to replace the windows.alert into a sweetalert?

<form class="w3-container" form method="POST" action="login.php" autocomplete="off">
        <div class="w3-section">
            <label><b><i class="fa fa-user"></i> Username</b></label>
            <input class="w3-input w3-border w3-margin-bottom" type="text" placeholder="Enter Username" name="username" required>
            <label><b><i class="fa fa-unlock-alt" id="iconcart"></i> Password</b></label>
            <input class="w3-input w3-border" type="password" placeholder="Enter Password" name="password" required>
            <button class="w3-button w3-block w3-green w3-section w3-padding" type="submit">Login</button>
            <input class="w3-check w3-margin-top" type="checkbox" checked="checked"> Remember me
        </div>
    </form>








 if ($_SERVER["REQUEST_METHOD"] == "POST") {
        $username=check_input($_POST['username']);

        if (!preg_match("/^[a-zA-Z0-9_]*$/",$username)) {
            ?>  
            <script>
                window.alert('Username should not contain space and special characters!');
                window.history.back();
            </script>
        <?php
        }
        else{

        $fusername=$username;

        $password = check_input($_POST["password"]);
        $fpassword=md5($password);

        $query=mysqli_query($conn,"select * from `user` where username='$fusername' and password='$fpassword'");

        if(mysqli_num_rows($query)==0){
            ?>

            <script>
                    window.alert('Login Failed, Invalid Username or Password!');
                    window.history.back();
                </script>
window.alert=function(event) {
    event.preventDefault();
    /* Your Sweetalert code here */  
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM