在url内重定向url
我在我的网站上有一个外部论坛登录表单,但在登录后,我希望用户重定向回访客在登录前查看的确切网站页面 我用的东西是:在url内重定向url,url,redirect,history,back,Url,Redirect,History,Back,我在我的网站上有一个外部论坛登录表单,但在登录后,我希望用户重定向回访客在登录前查看的确切网站页面 我用的东西是: <script> function goBack() { window.history.go(-1) } </script> <form action="./forum/ucp.php?mode=login" method="post"> <fieldset> <label for="username">Name:<
<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>
我只设法重定向到我网站的索引:
value="http://www.wow.com">
谁来帮我:?您可以按照以下代码操作:
<?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>
显示使用此隐藏字段的代码。我编辑了以下问题:您尚未显示使用重定向字段的PHP代码。如果只是把值放在Location:header中,那就行不通了;该标题包含URL,而不是Javascript。
<?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>