[英]I'm not able to redirect the URL to a different webpage after submiting form values
您好網站站長iam嘗試在提交表單元素后將網頁重定向到其他URL /網頁...我嘗試了多種方法,但無法修復...請檢查到目前為止我嘗試過的以下代碼...
<?php
if(isset($_REQUEST['down'])){
header("header("location: domainpath/kothi.html");
}
?>
<html>
<body>
<form action="glitter.php" method="post">
<input type="radio" name="font" value="fonts/darkcrystaloutline.ttf"/>
<input type="radio" name="font" value="fonts/darkcrystalout.ttf"/>
</form>
</body>
</html>
我也嘗試過
<?php
if(isset($_REQUEST['font'])){
header("location: domainpath/kothi.html");
};
?>
我也嘗試過
<?php
header("location: domainpath/kothi.html");
?>
請幫助我解決問題。
該文件是glitter.php
嗎? 重定向腳本應保存在glitter.php
因為這是您提交表單時將加載的頁面。
有幾種方法可以進行重定向。
通過元標記: http : //webdesign.about.com/od/metataglibraries/a/aa080300a.htm
通過標頭: http : //php.net/manual/en/function.header.php (您必須在標頭語句后放置exit
)
通過Javascript: http : //www.tizag.com/javascriptT/javascriptredirect.php
首先,以下內容:
<?php
if(isset($_REQUEST['down'])){
header("header("location: domainpath/kothi.html");
}
?>
這是不正確的, header
被錯誤地聲明,將header
替換為下面的header
:
<?php
if(isset($_REQUEST['down'])){
header("location: domainpath/kothi.html");
}
?>
其次,為什么$_REQUEST
呢? 您正在進行POST,第三, down
來自何處? 您的表單正在提交font
因此需要以下內容:
<?php
if(isset($_POST['font'])){
header("Location: domainpath/kothi.html");
exit();
}
?>
順便說一句,添加了exit()
來停止其余頁面的加載...
更新資料
如果您也提交了數據也可能是最好的,所以在<form>
標簽之間包括以下內容
<input type="submit" name="submit" value="Submit this form">
就像其他人指出的那樣,我希望這個PHP頁面被稱為glitter.php
以便它可以提交給自己...
更新2
根據您的評論,您需要以下內容:
<?php
if(isset($_POST['down'])){
header("location: domainpath/kothi.html");
exit();
}
?>
<html>
<body>
<form action="glitter.php" method="post">
<input type="radio" name="font" value="fonts/darkcrystaloutline.ttf"/>
<input type="radio" name="font" value="fonts/darkcrystalout.ttf"/>
<input type="submit" name="down" value="down">
</form>
</body>
</html>
盡管上面的表單將轉到glitter.php
,並且header
將不會重定向到任何地方-一個人必須假定另一表單/頁面提交了此表單/頁面。
您有action =“ glitter.php”,這意味着在提交表單后,結果輸入將可以訪問閃閃發光的.php文件。 因此,在該文件中,您必須重定向到您想使用的任何URL。
您已經問過一次這個問題,但是在這里添加:
error_reporting(E_ALL);
但是我有一個假設:您必須在header()cos之后做一個exit(),其余的不允許輸出。 如果提供輸出,則標題將設置為HTML文檔,因此無法重置。
所以試試這個:
<?php
if(isset($_REQUEST['down']))
{
header("location: /kothi.html");
exit();
}
?>
<html>
<body>
<form action="glitter.php" method="post">
<input type="radio" name="font" value="fonts/darkcrystaloutline.ttf"/>
<input type="radio" name="font" value="fonts/darkcrystalout.ttf"/>
</form>
</body>
</html>
順便說一句:我希望這種形式在glitter.php中,向下的輸入在哪里? 如果此文件不是閃光的,則將其添加為閃光的:
<?php
if(isset($_POST['font'])){
header("Location: domainpath/kothi.html");
exit();
}
?>
並殺死表單頁面中的php。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.