繁体   English   中英

提交表单值后,无法将URL重定向到其他网页

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM