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

发布于 2025-01-05 00:25:54 字数 768 浏览 4 评论 0原文

您好,网站管理员,我正在尝试在提交表单元素后将网页重定向到不同的 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");
?>

请帮我解决问题......

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

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

丶情人眼里出诗心の 2025-01-12 00:25:54

那个文件是glitter.php吗?重定向脚本应保存在 glitter.php 中,因为这是您提交表单时将加载的页面。

有多种方法可以进行重定向。

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

通过标头: http://php.net/manual/en/function.header.php(您必须在 header 语句之后放置 exit

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

Is that file 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.

There are several ways to do a redirect.

via meta tag: 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)

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

无远思近则忧 2025-01-12 00:25:54

首先,如下:

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

这是不正确的,header 声明不正确,将 header 替换为下面的 header

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

其次,为什么 $ _请求?你正在发一个 POST,第三,down 从哪里来?您的表单正在提交font,因此以下是您所需要的:

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

添加exit()以停止页面加载的其余部分,顺便说一句...

更新

如果您也提交了数据,这可能也是最好的,因此在

标记之间包含以下内容

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

正如其他人指出的那样,我希望这个 PHP 页面被称为 < code>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重定向到任何地方 - 必须假设另一个表单/页面提交给这个表单/页面...

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:

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

Secondly, why $_REQUEST? You're making a POST, and thirdly, where is down coming from? You form is submitting font so the following is what you need:

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

Update

It may also be best if you submitted the data too, so include the below inbetween the <form> tags

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

Update 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...

在巴黎塔顶看东京樱花 2025-01-12 00:25:54

您有 action="glitter.php",这意味着提交表单后,结果输入将可访问到 glitter.php 文件中。因此,在该文件中,您必须重定向到您想要访问的任何网址。

You have action="glitter.php", which means after submitting the form the result inputs will be accessible into glitter.php file. So in that file you have to redirect to whatever url you wanna go.

提笔书几行 2025-01-12 00:25:54

您已经问过这个问题一次,但在这里添加:

error_reporting(E_ALL);  

但我有一个假设:您必须在 header() 之后创建 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 中,down 的输入在哪里?
如果这个文件不是 glitter,请在 glitter: 中添加此文件,

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

并杀死表单页面中的 php。

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. If it gives an output the header will be set to a HTML-Document and can therefore not be reset.

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文