好吧,即時消失。我無法弄清楚如何在頭文件發送後重定向某人。這個腳本的目的是如果日期有效,他們會被重定向到編輯頁面。如果日期無效,則停止日期並告訴他們爲什麼無法編輯。標題設置後,重定向頁面使用php
<?php
$id = $_GET['id'];
// Define MySQL Information.
$mysqlhost="************************"; // Host name of MySQL server.
$mysqlusername="**************"; // Username of MySQL database.
$mysqlpassword="**************"; // Password of the above MySQL username.
$mysqldatabase="**************"; // Name of database where the table resides.
// Connect to MySQL.
mysql_connect("$mysqlhost", "$mysqlusername", "$mysqlpassword")or die("Could not connect to MySQL.");
mysql_select_db("$mysqldatabase")or die("Could not connect to selected MySQL database.");
$infosql = "SELECT * FROM premiersounds_users WHERE customer_id = $id";
$inforesult = mysql_query($infosql) or die(mysql_error());
$info = mysql_fetch_array($inforesult);
$l_date=$info['lockout_date'];
//Get current date from server
$format="%m/%d/%y";
$c_date=strftime($format);
//set sessions
$_SESSION['current_date'] = $c_date;
$_SESSION['lockout_date'] = $l_date;
//Check is Current date = lockout date
if ($c_date >= $l_date)
{ header("location:/planner_scripts/documnet_editors/edit_weddingplanner.php?id=$id"); } else {echo 'Whoops! Were sorry your account has been locked to edits because your event is less than 48 hours from now or your event has passed. To make changes to your event please contact your DJ.'; echo'<br/>'; echo ' Todays Date: ';echo $c_date; echo ','; echo ' Last Date for edits: '; echo $l_date;}
?>
爲什麼不把它放在沒有h讀者已經發送了嗎? – jeroen 2011-12-30 15:48:32
我不明白這個問題。 PS最好使用'Location:'(注意大寫L和冒號後的空格)作爲重定向頭。 – 2011-12-30 15:48:45