简体   繁体   English

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

[英]I'm not able to redirect the URL to a different webpage after submiting form values

Hello Webmasters iam trying to redirect the webpage to a different URL/webpage after submitting the form elements ...i tried many ways but could not fix it... please check the codes below that i have tried so far... 您好网站站长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>

i have also tried 我也尝试过

<?php
if(isset($_REQUEST['font'])){
    header("location: domainpath/kothi.html");
};
?>

i also tried 我也尝试过

<?php
header("location: domainpath/kothi.html");
?>

please help me to fix the problem.... 请帮助我解决问题。

Is that file glitter.php ? 该文件是glitter.php吗? The redirection script should be kept in glitter.php as that is the page that will be loaded when you submit the form. 重定向脚本应保存在glitter.php因为这是您提交表单时将加载的页面。

There are several ways to do a redirect. 有几种方法可以进行重定向。

via meta tag: http://webdesign.about.com/od/metataglibraries/a/aa080300a.htm 通过元标记: http : //webdesign.about.com/od/metataglibraries/a/aa080300a.htm

via header: http://php.net/manual/en/function.header.php (you have to put exit after the header statement) 通过标头: http : //php.net/manual/en/function.header.php (您必须在标头语句后放置exit

via Javascript: http://www.tizag.com/javascriptT/javascriptredirect.php 通过Javascript: http//www.tizag.com/javascriptT/javascriptredirect.php

Firstly, the below: 首先,以下内容:

<?php
if(isset($_REQUEST['down'])){
    header("header("location: domainpath/kothi.html");
}
?>

This is incorrect, the header is incorrectly declared, replace header with the header below: 这是不正确的, header被错误地声明,将header替换为下面的header

<?php
if(isset($_REQUEST['down'])){
    header("location: domainpath/kothi.html");
}
?>

Secondly, why $_REQUEST ? 其次,为什么$_REQUEST呢? You're making a POST, and thirdly, where is down coming from? 您正在进行POST,第三, down来自何处? You form is submitting font so the following is what you need: 您的表单正在提交font因此需要以下内容:

<?php
if(isset($_POST['font'])){
    header("Location: domainpath/kothi.html");
    exit();
}
?>

exit() is added to stop the rest of the page loading too, by the way... 顺便说一句,添加了exit()来停止其余页面的加载...

Update 更新资料

It may also be best if you submitted the data too, so include the below inbetween the <form> tags 如果您也提交了数据也可能是最好的,所以在<form>标签之间包括以下内容

<input type="submit" name="submit" value="Submit this form">

And like others point out, I hope this PHP page is called glitter.php so it can submit to itself... 就像其他人指出的那样,我希望这个PHP页面被称为glitter.php以便它可以提交给自己...

Update 2 更新2

Based on your comment, then you'd want the following: 根据您的评论,您需要以下内容:

<?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>

Though the above form will go to glitter.php and the header will not redirect anywhere - one has to assume that another form/page submits to this one... 尽管上面的表单将转到glitter.php ,并且header不会重定向到任何地方-一个人必须假定另一表单/页面提交了此表单/页面。

You have action="glitter.php", which means after submitting the form the result inputs will be accessible into glitter.php file. 您有action =“ glitter.php”,这意味着在提交表单后,结果输入将可以访问闪闪发光的.php文件。 So in that file you have to redirect to whatever url you wanna go. 因此,在该文件中,您必须重定向到您想使用的任何URL。

You already asked this question once, but here add this : 您已经问过一次这个问题,但是在这里添加:

error_reporting(E_ALL);  

But i have a assumption: You have to make an exit() after header() cos the rest is not allowed to be give an output. 但是我有一个假设:您必须在header()cos之后做一个exit(),其余的不允许输出。 If it gives an output the header will be set to a HTML-Document and can therefore not be reset. 如果提供输出,则标题将设置为HTML文档,因此无法重置。

So try this: 所以试试这个:

<?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>

BTW: I hope this form is in glitter.php and where is the input for down? 顺便说一句:我希望这种形式在glitter.php中,向下的输入在哪里? If this file is not glitter, add this in glitter: 如果此文件不是闪光的,则将其添加为闪光的:

<?php
if(isset($_POST['font'])){
    header("Location: domainpath/kothi.html");
    exit();
}
?>

And kill the php in the form-page. 并杀死表单页面中的php。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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