我有一個網頁的表單,像這樣:使用define()對網站的名稱
<form method="POST" action="scripts/save-settings2.php">
<div id="posts">
<div class="post">
<div>
<label for="siteName">Site Name</label>
<div class="input-wrap">
<input value="<?php echo constant('siteName'); ?>" type="text" name="siteName" />
</div>
</div>
<input type="submit" value="Save" />
<a href="posts.php" class="cancel">Cancel</a>
</div> <!--Post-->
</div> <!--Posts-->
</form>
的輸入變量的值發送到該腳本:
include '../includes/database-login.php';
if (isset($_POST['siteName'])) {
$siteName = mysql_real_escape_string($_POST['siteName']);
define("siteName", "$siteName");
header('Location: ../settings.php');
} else {
header('Location: ../newpost-error.php');
}
什麼我想do是將用戶填入siteName輸入字段的內容,並將其定義爲常量「siteName」,以便我可以在站點的其他地方回顯常量。由於某種原因,這是行不通的。我在這裏犯了一些明顯的錯誤嗎?
我覺得換頁是沒錯的問題 – codedude 2011-04-16 20:32:15
,只是測試它 – Calum 2011-04-16 20:33:43