1

我的网站上有一个外部论坛登录表单,但登录后我希望用户重定向回访问者在登录前查看的确切网站页面。

我用的东西:

<script>
function goBack()
{
window.history.go(-1)
}
</script>

<form action="./forum/ucp.php?mode=login" method="post">
<fieldset>
<label for="username">Name:</label><br>
<input type="text" name="username" id="username" size="20" class="input"><br>
<label for="password">Password:</label><br>
<input type="password" name="password" id="password" size="20" class="input"><br>
<label for="autologin">Remember<input type="checkbox" name="autologin" id="autologin"></label><br>
<input type="hidden" name="redirect" value="goBack()">
<input type="submit" name="login" value="Log in" class="button">
</fieldset>
</form>

但是,浏览器重定向到:

http://www.mysite.com/forum/goBack()?sid=87b53e6ecb0ae9062a3a9b930

我只设法重定向到我网站的索引:

value="http://www.wow.com">

谁来帮帮我:)?

4

1 回答 1

0

您可以按照以下代码:

<?php
//perform your post operations
if(isset($_POST['submit'])){
echo "<pre>";
print_r($_POST);
?>
<script>
window.history.go(-2); // -1 will post on the page from which it has been posted
</script>
<?php
    }
    ?>
    <html>
    <body>
    <form id="myForm" name="myForm" method="post">
    Name: <input type="text" name="name" id="fname">
    Email <input type="text" name="email" id="emailid">
    <input type="submit" name="submit" value="Submit" id="submit">
    </form>
    </body>
    </html>
于 2012-12-06T12:25:42.660 回答