使用 Google Signin API 时无法重定向到我的仪表板.PHP 文件?

问题描述 投票:0回答:1

我使用的代码是-->

    <div class="login">
        <form method="POST">
            <label for="chk" aria-hidden="true">Login</label>
            <input type="email" name="login_email" placeholder="Email" required="">
            <input type="password" name="login_password" placeholder="Password" required="">
            <button type="submit" name="login">Login</button>

            <div class="containergg">
                <label1 for="signup">Or signin with:</label1>
            </div>
            <div class="g-signin2" data-onsuccess="onSignIn"></div>
            <script>
                function onSignIn(googleUser) {
                    // Extract necessary information about the user
                    var profile = googleUser.getBasicProfile();
                    var userEmail = profile.getEmail();

                    // Check if user is signed in with Google
                    if (userEmail) {
                        // Redirect to dashboard.php
                        window.location.href = 'dashboard.php';
                    } else {
                        // Handle the case where the user is not signed in
                        console.log('User not signed in.');
                    }
                }
            </script>
        </form>
    </div>

注册逻辑相同

我期待,登录后应该会带我到dashboard.php 文件。`

javascript php html google-signin
1个回答
0
投票

试试这个:

var url = "example.com";
window.open(url);
© www.soinside.com 2019 - 2024. All rights reserved.