我的頁面的URL是一樣的東西http://localhost/coursera/instructor/course.php?id=1&name=web%20development§ion=overview
,並在該網頁上我有一個像
<form action="<?php echo $_SERVER["PHP_SELF"];?>" method="post">
<div class="form-group">
<textarea class="form-control" placeholder="What will students need to know or do before starting this course? Who is your target student? At the end of my course, students will be able to..." rows="8" required="" name="description"></textarea>
</div>
<button type="submit" class="btn btn-info btn-fill btn-block" name="overview">Save</button>
</form>
形式,但問題是<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>
和<?php echo $_SERVER["PHP_SELF"];?>
不與所有的$ _Get值返回相同的URL。
無論如何,使表單返回到同一頁面,因爲我不能硬編碼$ _Get值。
謝謝。
編輯:
print_r($_SERVER["PHP_SELF"]);
是顯示/coursera/instructor/course.php
但我想http://localhost/coursera/instructor/course.php?id=1&name=web%20development§ion=overview
任何方式做到這一點?
'的print_r($ _ SERVER)',看看你可以用什麼 –
@Federkun我想,當我提交表單我應該返回到相同的URL,但它不是 – Phoenix