Ecco il codice per sfruttare il login e registrazione del phpbb2 per poter fare registrare e loggare i vostri utenti dall'index pricipale del vostro sito.
Codice:
<?php
$db_hostname = "localhost";
$db_username = "username";
$db_password = "password";
$db_name = "my_database";
$dbcon = mysql_connect($db_hostname, $db_username, $db_password);
mysql_select_db("$db_name");
$login = " <p><span class=\"genmed\">
<form action=\"forum/login.php\" method=\"post\">
<input value=\"../index.php\" name=\"redirect\" type=\"hidden\">
Username:<br /><input size=\"15\" name=\"username\" type=\"text\" class=\"post\"><br />
Password:<br /><input size=\"15\" name=\"password\" type=\"password\" class=\"post\"><br />
<br />
<input value=\"ON\" name=\"autologin\" type=\"hidden\">
<input value=\"Login\" name=\"login\" class=\"mainoption\" type=\"submit\"></form><br /><br />
<a class=\"gensmall\" href=\"forum/profile.php?mode=sendpassword\">Ho dimenticato la password</a><br />
<br />
Non hai ancora un account?<br />
Ti puoi <a href=\"forum/profile.php?mode=register\">registrare</a> gratuitamente</span>
</span></p>\n";
if (isset($HTTP_COOKIE_VARS[tfkbb2log_sid])) {
$session_id = $HTTP_COOKIE_VARS[tfkbb2log_sid];
$query = "SELECT session_id, session_user_id, session_logged_in FROM bb_sessions WHERE session_id='$session_id'";
$result = mysql_query($query, $dbcon);
$row = mysql_fetch_array($result);
if ($session_id === $row[session_id]) {
if ($row[session_logged_in] == "1") {
$query2 = "SELECT username FROM bb_users WHERE user_id='$row[session_user_id]'";
$result2 = mysql_query($query2, $dbcon);
$row2 = mysql_fetch_array($result2);
echo "Benvenuto $row2[username]";
}
else {
echo $login;
}
}
else {
echo $login;
}
}
else {
echo $login;
}
?>
Ciao!