When I press the submit button, it redirects me to a blank page. I want it to redirect to home.php. And if a GUEST press the submit button, in the database, the ANONYMOUS column is updated. How to redirect guest to login form if they are not connected? This is my code:
<?php
define('IN_PHPBB', true);
$phpbb_root_path = 'forum/';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);
include($phpbb_root_path . 'includes/functions_display.' . $phpEx);
include_once($phpbb_root_path . 'includes/functions_user.' . $phpEx);
include_once($phpbb_root_path . 'includes/functions.' . $phpEx);
// Start session management
$user->session_begin();
$auth->acl($user->data);
$user->setup();
$submit = request_var('submit', '');
if($submit)
{
$sql_ary = array("server"=> 3);
$sql = 'UPDATE ' . 'phpbb5u_users' . '
SET ' . $db->sql_build_array('UPDATE', $sql_ary) . '
WHERE user_id = ' . (int) $user->data['user_id'];
$db->sql_query($sql);
}
from doc https://www.phpbb.com/support/docs/en/3.2/kb/article/phpbb3-sessions-integration
you need add this code at the top page
<?php
define('IN_PHPBB', true);
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);
// Start session management
$user->session_begin();
$auth->acl($user->data);
$user->setup();
and now validating if guest submit data
<?php
if ($user->data['user_id'] == ANONYMOUS)
{
header("Location: loginform.php");
// EXECUTE YOUR SQL QUERY UPDATE HERE
}
else
{
header("Location: home.php");
}