我设计了一个网页。一页包含 html 用户注册表:
<form action="internal/signup.php" method="post" name="signupform" id="signupform">
<table width="444" border="0" cellspacing="6">
<tr>
<th width="98"align="right" scope="col"><label id="fnamelabel" for="fnam">First Name :</label></th>
<th width="286" align="center" scope="col"><input type="text" name="fnam" id="fnam" tabindex="1" /></th>
<td width="34" align="center" scope="col"><div id="ll"></div></td>
</tr>
<tr>
<th align="right" scope="row"> <label id="lnamelabel" for="lnam"> Last Name :</label></th>
<td align="center"><input type="text" name="lnam" id="lnam" tabindex="2" /></td>
<td align="center"><div id="lj"></div></td>
</tr>
<tr>
<th align="right" scope="row"><label id="youremail" for="email">Your Email :</label></th>
<td align="center"><input type="text" name="email" id="email" tabindex="3" /></td>
<td align="center"><div id="lk"></div></td>
</tr>
<tr>
<th align="right" scope="row"><label id="reemail" for="remail"> Password :</label></th>
<td align="center"><input type="password" name="password" id="password" tabindex="4" /></td>
<td align="center"><div id="ll2"></div></td>
</tr>
<tr>
<th align="right" scope="row"><label id="npass" for="password">Re-Password:</label></th>
<td align="center"><input type="password" name="repassword" id="repassword" tabindex="5" /></td>
<td align="center"><div id="lm"></div></td>
</tr>
<tr>
<th align="right" scope="row"><label id="skill" for="bskill">Skilled Area :</label></th>
<td align="center"><select name="bskill" id="bskill" tabindex="6">
<option>Graphics and multimedia</option>
<option>Art Works</option>
<option>IT & programming</option>
</select></td>
<td align="center"> </td>
</tr>
<tr>
<th colspan="3" align="left" scope="row" id="terms">By clicking "Sign up", you are indicating that you have read and agreed our <a href="index.html">Terms & conditions.</a></label></th>
</tr>
</table>
<td align="center"><div id="signupbutton"></div></td>
<td align="center">
</form>
当我单击注册按钮时,它会转到注册.php并完成注册,但我需要在注册完成后重定向到用户的页面。(类似于Facebook或Twitter在注册完成后自动定向到用户页面的方式(
谁能帮我?
注册完成后使用header()
:
<?php
header('Location: users.php');
exit;
?>
请记住,在发送任何实际输出之前,必须调用 header((,无论是通过普通的 HTML 标记、文件中的空行还是从 PHP 发送。
<?php
header("Location: http://www.example.com/"); /* Redirect browser */
/* Make sure that code below does not get executed when we redirect. */
exit;
?>
使用 header()
。
记得在header()
后使用die()
或exit()
。如果不使用其中之一,则代码将在重定向后继续执行。
header()
必须在任何输出之前使用。
<?php
// Redirect the user to wherever you want to go
header("Location: /users.php");
// Make sure none of the code beneath here is executed
die();
?>
必须在任何内容之前发送此代码。
更多文档可以在这里找到:http://es.php.net/manual/en/function.header.php