session_start();
if(count($_GET) > 0) {
$_SESSION["get"] = $_GET;
$dir = dirname($_SERVER["PHP_SELF"]);
if(($dir == "/") || ($dir == "\\")) {
$dir = "";
}
header("Location: http://".$_SERVER["SERVER_NAME"].$dir);
die();
}
如何在 http://".$_SERVER["SERVER_NAME"]. 后面添加上用户的注册名?使地址变成http://www.mysite.com/注册用户名
?
Location: http://".$_SERVER["SERVER_NAME"].$dir.后面加$_SERVER["QUERY_STRING"] ,$_SERVER["REQUEST_URI"] 都试过了,不行……
或者是登录前的HTML的输入框里面的值,你给的这段代码看不出从哪里获取注册用户名
然后在PHP中用$_POST['username']来获取用户名
{ tag: "div", html: loc.text("inp_email") },
{ tag: "div",
childs: [
{ tag: "input", id: "login_email", size: "30",
type: "text" }
]},
{ tag: "div", html: loc.text("inp_pwd") },
{ tag: "div",
childs: [
{ tag: "input", id: "login_pwd", size: "30",
type: "password" }
]},
{ tag: "div", style: { textAlign: "center", marginTop: "12px"},
childs: [
{ tag: "input", id: "login_btn",
events: { onclick: "d194()"},
type: "button", value: loc.text("auth_load_my_page") }
]},
{ tag: "div", id: "login_msg",
style: { marginTop: "12px", textAlign: "justify"}},
判断登陆的PHP代码如下(不是写在index.php里面的。require_once("email.php");class module extends controller { var $params = array("act");
var $isNeedMysql = true;
function createAnonymus() {
$this->db->query("INSERT INTO "._DB_TABLE_PREFIX."users (email, password) VALUES ('','')");
return $this->db->getLastId();
}
function run() {
$user_id = isset($_REQUEST['user_id']) ? getSafeStr($_REQUEST['user_id']) : null;
$email = isset($_REQUEST['email']) ? getSafeStr($_REQUEST['email']) : null;
$password = isset($_REQUEST['password']) ? getSafeStr($_REQUEST['password']) : null; switch($this->act) {
case "start_anonymus":
if($user_id) {
$res = $this->db->query("SELECT id FROM "._DB_TABLE_PREFIX."users WHERE id = '".$user_id."' AND email = '' AND password = '' LIMIT 1");
if($res) {
$res_id = $res["id"];
} else {
$res_id = $this->createAnonymus();
}
} else {
$res_id = $this->createAnonymus();
}
$_SESSION['user_id'] = $res_id;
return array("status" => "start_result",
"user" => array("id" => $res_id,
"email" => "",
"password" => ""));
break; case "start_user":
if($email && $password) {
if($res = $this->db->query("SELECT id FROM "._DB_TABLE_PREFIX."users WHERE email='".$email."' AND password='".$password."' LIMIT 1")) {
$_SESSION['user_id'] = $res["id"];
return array("status" => "start_result",
"user" => array("id" => $res["id"],
"email" => $email,
"password" => $password ) );
}
}
$res_id = $this->createAnonymus();
$_SESSION['user_id'] = $res_id;
return array("status" => "start_result",
"user" => array("id" => $res_id,
"email" => "",
"password" => ""));
break; case "login_user":
if(!$email || !$password) {
return false;
}
$sql = "
SELECT
id, email
FROM
"._DB_TABLE_PREFIX."users
WHERE
email='".$email."' AND password='".$password."'
LIMIT 1";
$res = $this->db->query($sql);
if(isset($res["id"])) {
$_SESSION['user_id'] = $res["id"];
return array("status" => "login_ok",
"user" => array("id" => $res["id"],
"email"=>$email,
"password"=>$password ) );
} else {
return array("status" => "login_error");
}
break;不知有谁可以看懂,教教我。