0

I'm working with openid library and one thing has been bodering me.

<?php
# Logging in with Google accounts requires setting special identity, so this example shows how to do it.
require 'openid.php';
try {
    # Change 'localhost' to your domain name.
    $openid = new LightOpenID('localhost');
    if(!$openid->mode) {
        if(isset($_GET['login'])) {
            $openid->identity = 'https://www.google.com/accounts/o8/id';
            header('Location: ' . $openid->authUrl());
        }
?>
<form action="?login" method="post">
    <button>Login with Google</button>
</form>
<?php
    } elseif($openid->mode == 'cancel') {
        echo 'User has canceled authentication!';
    } else {
        echo 'User ' . ($openid->validate() ? $openid->identity . ' has ' : 'has not ') . 'logged in.';
    }
} catch(ErrorException $e) {
    echo $e->getMessage();
}

when we click the button it gives ?login to the page and then the php checks it and redirects it to the page it must be redirected but the thing is after the login (in google or etc) the button will not be shown , if you want to see the example completly I uploaded it to http://dota2tradebots.com/googlelogin.php to test it yourself and see what I mean.
why isn't the button be shown after the login is complete ?

2
Contributors
2
Replies
19
Views
4 Years
Discussion Span
Last Post by Atli
0

I found out it by luck , this is a thing that is not written much , if you open a { and don't finish it when the php ends the things in the html will be in the if !

0

This behaviour tends to be mentioned in tutorials dealing with the basics of PHP. Take a look, for example, at this example in the Simple Tutorial in the PHP manual.

It's usually better to avoid mixing HTML and PHP like this though. Code like that usually ends up becoming very tedious to read and, therefore, maintain. Employing some sort of a templating system solves that nicely. - The idea is to keep the PHP logic and the template generation separate from each other.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.