php注册页面提交成功后如何 跳转成功页面??

我的代码如下
<?
include"sql.php";

insert_sql ("INSERT INTO `user` ( `userid` , `name` , `password` , `leixing` , `email` , `sexual` , `qq` , `address` , `ip` , `time` )
VALUES (
'', '$name', '$password', '$leixing', '$email', '$sexual', '$qq', '$address', '$REMOTE_ADDR',NOW( )
);");

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>buyerchina华人学院</title>
</head>

<body>
<form id="form1" name="form1" method="post" action="">
<table width="688" border="0" cellpadding="3">
<tr>
<td width="206">用户名</td>
<td width="664"><input name="name" type="text" id="name" /></td>
</tr>
<tr>
<td>密码</td>
<td><input name="password" type="password" id="password" /></td>
</tr>
<tr>
<td>邮箱地址</td>
<td><input name="email" type="text" id="email" /></td>
</tr>
<tr>
<td>会员类型</td>
<td><select name="leixing" id="leixing">
<option value="vip">vip</option>
</select>
</td>
</tr>
<tr>
<td>性别</td>
<td><select name="sexual" id="sexual">
<option value="男">男</option>
<option value="女">女</option>
</select> </td>
</tr>
<tr>
<td>QQ</td>
<td><input name="qq" type="text" id="qq" /></td>
</tr>
<tr>
<td>居住城市省份</td>
<td><input name="address" type="text" id="address" value="" /></td>
</tr>

<tr>
<td> </td>
<td><input type="submit" name="Submit" value="递交" /></td>
</tr>
</table>

</form>
</body>
已经能插入数据库,但不知道如何实现??
1--当/写入成功
就显示"注册成功";跳转到用户会员页面vip.php

2---当用户名已存在/如果无法写入
显示“注册失败。请<a href='register.php'>重试</a>.";

PHP页面跳转一、header()函数
header()函数是PHP中进行页面跳转的一种十分简单的方法。header()函数的主要功能是将HTTP协议标头(header)输出到浏览器。
header()函数的定义如下:
void header (string string [,bool replace [,int http_response_code]])
可选参数replace指明是替换前一条类似标头还是添加一条相同类型的标头,默认为替换。
第二个可选参数http_response_code强制将HTTP相应代码设为指定值。 header函数中Location类型的标头是一种特殊的header调用,常用来实现页面跳转。注意:1.location和“:”号间不能有空格,否则不会跳转。
2.在用header前不能有任何的输出。
3.header后的PHP代码还会被执行。例如,将浏览器重定向到lamp兄弟连官方论坛
< ?php
//重定向浏览器
header("Location: http://bbs.
lampbrother.net");
//确保重定向后,后续代码不会被执行
exit;
?>
PHP页面跳转二、Meta标签
Meta标签是HTML中负责提供文档元信息的标签,在PHP程序中使用该标签,也可以实现页面跳转。 若定义http-equiv为refresh,则打开该页面时将根据content规定的值在一定时间内跳转到相应页面。
若设置content="秒数;url=网址",则定义了经过多长时间后页面跳转到指定的网址。例如,使用meta标签实现疫苗后页面自动跳转到。
< meta http-equiv="refresh"
content="1;url=http://
bbs.lampbrother.net">

例如,以下程序meta.php实现在该页面中停留一秒后页面自动跳转到bbs.lampbrother.net。
< ?php $url = "http://bbs.lampbrother.net"; ?> < html> < head> < meta http-equiv="refresh" content="1; url=< ?php echo $url; ?>"> < /head> < body> 页面只停留一秒…… < /body> < /html>

PHP页面跳转三、JavaScript
例如,此代码可以放在程序中的任何合法位置。
< ?php $url = "http://bbs.lampbrother.net"; echo "< script language='javascript' type='text/javascript'>"; echo "window.location.href='$url'"; echo "< /script>"; ?>
温馨提示:答案为网友推荐,仅供参考
第1个回答  2008-05-18
header("location:vip.php");
用户名的话就要用sql查询数据库里面的名字,然后对比,不对的话在重试
第2个回答  推荐于2018-02-27
if(insert_sql("省略.."))
echo '<script language="JavaScript">window.location.href="vip.php";</script>';
else {
echo '<script language="JavaScript">alter("重试");</script>'
echo '<script language="JavaScript">window.location.href="register.php";</script>';
}本回答被提问者和网友采纳

相关了解……

你可能感兴趣的内容

本站内容来自于网友发表,不代表本站立场,仅表示其个人看法,不对其真实性、正确性、有效性作任何的担保
相关事宜请发邮件给我们
© 非常风气网