FRIHOSTFORUMSSEARCHFAQTOSBLOGSDIRECTORY
You are invited to Log in or Register a Frihost Account!

php login module

 


nunosilva
Actually it's not a module...

I've managed to put into a <td> a login script. The question is... whenever ther user and pass are correct, I'd like to change on that part of the table, the form into something like "Welcome user" and a link with a logout option....

is it possible? well..... it is! hjow to do it?!

Nuno Silva Shocked
mathiaus
Well if you set a cookie or a session or something to say their logged in use a simple if.

Code:
<?php
if (isset $_COOKIE['loggedinas') {
echo "Welcome" . $_COOKIE['loggedinas'] . "!";
} else {
echo "<a href=/"login.php/">Login</a> | <a href=/"register.php/">Register</a>";
}
?>


Things can be added to make it more complex and add more features but thats the basics.

If you can be more specific, we can to Wink
dandelion
Also you can use the AuthPEAR::Auth package as shown below (code from Auth tutorial).
Code:
<?<?php
require_once "Auth.php";

function loginFunction()
{
    /*
     * Change the HTML output so that it fits to your
     * application.
     */
    echo "<form method=\"post\" action=\"test.php\">";
    echo "<input type=\"text\" name=\"username\">";
    echo "<input type=\"password\" name=\"password\">";
    echo "<input type=\"submit\">";
    echo "</form>";
}

$dsn = "mysql://user:password@localhost/database";
$a = new Auth("DB", $dsn, "loginFunction");

$a->start();

if ($a->checkAuth()) {
    /*
     * The output of your site goes here.
     */
}
?>?>

Just insert it into the <td> and replace commented lines with Welcome user or like.
Related topics

PHP login/logout problem
PHP Login Problem
php+mysql password / login screen
php login (with flash)
my first php login w/o database

Flex + PHP login
MSN network php login?
Frih$ on offer for PHP Login System
PHP login script problem
Free php script login / register , GREAT!

PHP Login Sessions & Security with Frihost
Adding PHP to My HTML site
[Community Project] Easy Simple Content Management System
150 frih$ if you make me a login script with....
Authentication Module
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2007 Frihost, forums powered by phpBB.