Im trying to intergrate the PhpBB login to a page, but I just can't get it to work properly. Im stuck at the redirect after login was succeeded. The script is redirecting me back to the forum index and with the meta refresh I am getting an error.
I also tried to not redirect and to be satisfied with a messege that Im logged in. I have let the action empty in the form but then Im receiving header errors.
Code: Select all
<form method="POST" action="">
Code: Select all
[phpBB Debug] PHP Notice: in file /includes/session.php on line 990: Cannot modify header information - headers already sent by (output started at /home/apje14/public_html/bendeboy/ProjectHT/paginas/request.php:16)
[phpBB Debug] PHP Notice: in file /includes/session.php on line 990: Cannot modify header information - headers already sent by (output started at /home/apje14/public_html/bendeboy/ProjectHT/paginas/request.php:16)
[phpBB Debug] PHP Notice: in file /includes/session.php on line 990: Cannot modify header information - headers already sent by (output started at /home/apje14/public_html/bendeboy/ProjectHT/paginas/request.php:16)
Login Successful! Welcome Administrator
This is the location of the forum: /home/apje14/public_html/forum/
And here is my script:
Code: Select all
<?php
define('IN_PHPBB', true);
$phpbb_root_path = '../../../forum/';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);
// Start session management
$user->session_begin();
$auth->acl($user->data);
$user->setup();
?>
<html>
<head>
<title>SHOUT</title>
</head>
<BODY STYLE="background-color: transparent">
<?php
if($user->data['is_registered'])
{
//User is already logged in
include("functions.php");
include("../hooizolder/connector.php");
if(isset($_POST["name"]) && isset($_POST["message"]))
{
$username = clean($_POST["name"]);
$message = clean($_POST["message"]);
$dj = clean($_POST["DJ"]);
$type = clean($_POST["type"]);
if($username == "" || $message == "")
{
echo("Sorry, you have left a field blank, please click <a href=\"request.php\" target=\"_self\">here</a> to go back.");
unset($_POST["name"]);
unset($_POST["message"]);
exit;
}
mysql_query("INSERT INTO `requests` (`sender`, `dj`, `message`, `date`, `type`, `ip`) VALUES ('$username', '$dj', '$message', '".gmdate("d/m/Y - h:i:s")."', '$type', '".$_SERVER["REMOTE_ADDR"]."')");
echo("Thanks for sending in a request, $username.<br />Please feel free to navigate away from this page, or return to the request line by clicking <a onclick=\"dopage('request.php', 'content');\">here</a>");
exit;
}
else
{
?>
<form action="" method="post">
<table border="0" width="275" cellspacing="0" cellpadding="0" id="table1">
<tr>
<td>Naam:</td>
<td><b><? echo $user->data['username']; ?></b> <input type="hidden" name="name" size="29" value="<? echo $user->data['username']; ?>"><br /></td>
</tr>
<tr>
<td>Type bericht:</td>
<td><select name="type">
<option>--------- Selecteer ---------</option>
<option selected>Verzoek een nummer</option>
<option>Shout</option>
<option>Competitie inzending</option>
<option>Mop inzenden</option>
<option>Overige...</option>
</select>
</td>
</tr>
<tr>
<td valign="top">Bericht:</td>
<td valign="top"><textarea name="message" rows="4" cols="30"></textarea><br /></td>
</tr>
<tr>
<td></td>
<td><input type="submit" name="submit" value="Verstuur!"></td>
</tr>
</table>
</form>
<?php
}
}
else
{
function display_login_box()
{
echo '<form method="POST" action="">
<table border="0" width="275" cellspacing="0" cellpadding="0" id="table1">
<tr>
<td>Gebruikersnaam: </td>
<td><input type="text" name="username" size="40"></td>
</tr>
<tr>
<td>Wachtwoord:</td>
<td><input type="password" name="password" size="40"></td>
</tr>
<tr>
<td>Onthoud?: <input type="checkbox" name="autologin"></td>
<td><input type="submit" value="Login" name="login"></td>
</tr>
</table>
<input type="hidden" name="redirect" value="request.php">
</form>';
}
$username = request_var('username', '', true);
$password = request_var('password', '', true);
$autologin = (!empty($_POST['autologin'])) ? true : false;
$result = $auth->login($username, $password, $autologin);
if ($result['status'] == LOGIN_SUCCESS)
{
echo "Login Successful! Welcome " . $user->data['username'];
//User was successfully logged into phpBB
// append/replace SID
$redirect = reapply_sid('request.php');
meta_refresh(0, $redirect);
}
else
{
display_login_box();
}
}
?>
</body></html>
Kind regards,
Daniel