我该如何处理?
我允许用户通过各种社交网站登录。我得到他们的唯一标识符,然后将他们重定向到其他页面
$id = ($profile->identifier);
$newURL = "/your-data/$id";
header('Location: '.$newURL);
,在那里他们将能够存储一些关于自己的数据。
我知道,我会在这里获得所有必要的数据,并将其保存到数据库中。
我想,关于/你的数据/98432048320
显示从/template/header,index,footer.php 生成的网站
以下是我迄今为止所做的工作:
关于您的数据/index.php
<?php
include("templates/header.htm");
// Set the default name
$action = 'index';
// Specify some disallowed paths
$disallowed_paths = array('header', 'footer');
if (!empty($_GET['action'])) {
$tmp_action = basename($_GET['action']);
// If it's not a disallowed path, and if the file exists, update $action
if (!in_array($tmp_action, $disallowed_paths) && file_exists("templates/{$tmp_action}.htm"))
$action = $tmp_action;
}
// Include $action
include("templates/$action.htm");
include("templates/footer.htm");
?>
我跑不动了。它只是简单的PHP,没有框架。。。
您不应该为每个唯一的用户生成几十个模板。这将是非常多余的
相反,制作一个php
文件,我们称之为content.php
(不管怎样)
这样的文件可以包含分别针对特定用户动态生成的数据
将content.php
包含在主index.php
中
您的数据/index.php:
<?php
include("templates/header.htm");
$action = 'index'; // Set the default name
if (!empty($_GET['action'])) {
$tmp_action = basename($_GET['action']);
if (is_numeric($tmp_action)){ // check if user identifier was passed in
include("templates/content.php");
}
}
include("templates/footer.htm");
?>
现在$tmp_action
变量可以在content.php
中自由访问
content.php:
<?php
$userId = (int) $tmp_action;
// possible case
$query = "SELECT name, age, activity FROM social_users WHERE id = ". $userId;
// here you can get all needed data for certain user
// which can be shown in #mainContainer div
?>
<div id="mainContainer"></div>