简体   繁体   English

提交按钮后的空白页和匿名列在提交按钮后更新

[英]Blank page after submit button & Anonymous column is updated after submit button

When I press the submit button, it redirects me to a blank page.当我按下提交按钮时,它会将我重定向到一个空白页面。 I want it to redirect to home.php.我希望它重定向到 home.php。 And if a GUEST press the submit button, in the database, the ANONYMOUS column is updated.如果一个 GUEST 按下提交按钮,在数据库中,匿名列被更新。 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);
}

To redirect guest to login use session:要将访客重定向到登录,请使用 session:

if (!isset($_SESSION['login'])) { 
    header("Location: login.php");
}

from doc https://www.phpbb.com/support/docs/en/3.2/kb/article/phpbb3-sessions-integration来自文档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");
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM