我有一個PHP頁面,我想分享像UserID,密碼這樣的頁面之間的一些數據。我如何在PHP頁面之間共享數據?
我正在學習會話,我不知道我是否正確使用它。
<?php
require_once('database.inc');
$kUserID = $_POST['kUserID'];
$kPassword = $_POST['kPassword'];
if (!isset($kUserID) || !isset($kPassword)) {
header("Location: http://domain/index.html");
}
elseif (empty($kUserID) || empty($kPassword)) {
header("Location: http://domain/index.html");
}
else {
$user = addslashes($_POST['kUserID']);
$pass = md5($_POST['kPassword']);
$db = mysql_connect("$sHostname:$sPort", $sUsername, $sPassword) or die(mysql_error());
mysql_select_db($sDatabase) or die ("Couldn't select the database.");
$sqlQuery = "select * from allowedUsers where UserID='" . $kUserID . "' AND passwordID='" . $kPassword . "'";
$result=mysql_query($sqlQuery, $db);
$rowCheck = mysql_num_rows($result);
if($rowCheck > 0){
while($row = mysql_fetch_array($result)){
session_start();
session_register('kUserID');
header("Location: link.php");
}
}
else {
echo 'Incorrect login name or password. Please try again.';
}
}
?>
橙色,請清理您的代碼段從所有不相干的東西剝開它,並告訴我們你想與會話做的正是有太多的代碼,它不是縮進很好 - 沒有樂趣找出你想在這裏做什麼 – 2010-02-24 01:25:54
好吧,我做了你問什麼 我怎麼能在頁面之間共享數據 – orange 2010-02-24 01:37:07