简体   繁体   中英

How to get PHP echo to jQuery popup alert?

I use the below codes for email conformation:

using URL: /my_web/back-end/email-verify.php?email=email@gmail.com&code=Vruxc9JQwZEKjbz3HbZ2KlGPX10mJneDmH67hILqFooXeJIQb9

After the verification how can I get the jQuery to pop up on the index page?
Is there any possible way to get PHP echo value to jQuery?

    if(isset($_GET['email']) && !empty($_GET['email']) AND isset($_GET['code']) && !empty($_GET['code'])){
    // Verify data
    $email = mysqli_escape_string($conn,$_GET['email']); // Set email variable
    $hash = mysqli_escape_string($conn,$_GET['code']); // Set hash variable

    $sql="SELECT * FROM users WHERE user_email='".$email."' AND hashid='".$hash."' AND valied_user_1='0'";

   $search = mysqli_query($conn,$sql);


    if(mysqli_num_rows($search) > 0){
        // We have a match, activate the account
        $update="UPDATE users SET valied_user_1='1' WHERE user_email='".$email."' AND hashid='".$hash."' AND valied_user_1='0'";
        mysqli_query($conn,$update);
        echo"success";
        }else{
       ///other echo
    }  

jQuery Function :

$(document).ready(function(){
    if(success){
                            $('#alert').addClass('alert-success alert-dismissible fade show');
                            $('#alertText').html('Your account has been activated, you can now login.');
                            $('.modal4').show();
                            }
    });

HTML Modal4 :

<div class="modal4">
            <div class="container alert-popup">
                <div id="alert" class="alert">
                    <button type="button" id="alertcloss" class="close">&times;</button>
                    <p id="alertText"></p>
                </div>
            </div>
        </div>

Redirect the email_validation.php to index.php page with the GET parameters. http://sample.com/index.php?success=1 and on the index.php page do like

<div class="modal4">
            <div class="container alert-popup">
                <div id="alert" class="alert">
                    <button type="button" id="alertcloss" class="close">&times;</button>
                    <p id="alertText"></p>
                </div>
            </div>
        </div>


<?php 
if(isset($_GET['success']) {
?>
$(document).ready(function(){
                            $('#alert').addClass('alert-success alert-dismissible fade show');
                            $('#alertText').html('Your account has been activated, you can now login.');
                            $('.modal4').show();
});
<?php
}
?>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM