PHP 注册页面如何制作? 有没有PHP的注册页的例子啊。.. 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 简单的HTML表单提交关键是后面的对数据库的操作,你刚接触的话应该是对这个不太熟悉。第一步:打开数据库链接:$localhost="localhost";$user="root";$password="123456";$db="mydb";function db_connect($user,$password,$db){ mysql_connect($localhost, $user, $password) //链接函数 or die('I cannot connect to db: ' . mysql_error()); //链接失败将返回错误信息 mysql_select_db($db); //选择使用的数据库} db_connect(); //打开数据库第二步:数据库操作:1、插入数据$sql = "insert into users (username, email, password) values ('".$_POST["name"]."', '".$_POST["email"]."', '".$passwords[0]."')";$result = mysql_query($sql); //得到查询结果if ($result){ echo "It's entered!";} else { echo "There's been a problem: ".mysql_error();} 2、查询并显示数据$sqlAll = "select * from users";$result = mysql_query($sqlAll);$row = mysql_fetch_array($result); //得到记录集的一行,放到数组row中while ($row) { echo $row["username"]." -- ".$row["email"]."<br />";} 第三步:释放并关闭数据库链接@mysql_free_result($result);mysql_close();//执行完后关闭数据库 <head><meta http-equiv="Content-Type" content="text/html; charset=gb2312" /><title>增加用户</title><style type="text/css"><!--.STYLE1 { color: #FFFFFF; font-weight: bold;}--></style></head><body><?phpif($_POST['submit']){ $wyx_name=$_POST['wyx_name']; $wyx_pass=md5(trim($_POST['wyx_pass1'])); $sql="INSERT INTO wyx_user (wyx_name,wyx_pass) VALUES ('$wyx_name','$wyx_pass')"; $result=mysql_query($sql); header("Location:admin_user.php");}else{?><form method="post" name="form1" action="<?php echo $PATH_INFO;?>"><table width="400" border="0" align="center" cellpadding="5" cellspacing="1" bgcolor="#666666"> <tr> <td colspan="2" align="center" bgcolor="#666666" class="STYLE1">增加新用户</td> </tr> <tr> <td width="150" align="right" bgcolor="#FFFFFF">用户名:</td> <td width="250" bgcolor="#FFFFFF"><input name="wyx_name" type="text" size="17"/> <font color=red>*</font></td> </tr> <tr> <td width="150" align="right" bgcolor="#FFFFFF">密码:</td> <td width="250" bgcolor="#FFFFFF"> <input name="wyx_pass1" type="password" size="18"/> <font color=red>*</font></td> </tr> <tr> <td width="150" align="right" bgcolor="#FFFFFF">重复密码:</td> <td width="250" bgcolor="#FFFFFF"> <input name="wyx_pass2" type="password" size="18"/> <font color=red>*</font></td> </tr> <tr> <td colspan="2" align="center" bgcolor="#FFFFFF"><input type="submit" name="submit" value="提交" /></td> </tr></table></form><?php}?></body>这个没有对两次输入的密码进行验证连接数据库的代码就不要我写了吧 你首先应该学习的是如何使用google 我想自己编译个php的memcache.dll可是要怎么编译呢? gb2312转换utf-8文件编码问题,急急 php支持跨数据库的事物吗? 小妹有一事不明 这是怎样实现的? 希望有空间的朋友帮忙|? 不知道大家有没有遇到象小妹这样的情况!小妹感到很烦恼! 高手请进!关于扩展PHP函数的问题! 求教大侠,一个困扰我已久的问题? php foreach 里面不相等的值显示出来的 Incorrect string value: '\xBC\xD3\xCB\xD9\xD2\xB3...' 无语的错误 100分悬赏! PHP做周历,谁有做好的代码?或者提供我周历的算法也行!
$user="root";
$password="123456";
$db="mydb";
function db_connect($user,$password,$db){
mysql_connect($localhost, $user, $password) //链接函数
or die('I cannot connect to db: ' . mysql_error()); //链接失败将返回错误信息
mysql_select_db($db); //选择使用的数据库
} db_connect(); //打开数据库第二步:数据库操作:1、插入数据$sql = "insert into users (username, email, password) values ('".$_POST["name"]."', '".$_POST["email"]."', '".$passwords[0]."')";
$result = mysql_query($sql); //得到查询结果
if ($result){
echo "It's entered!";
} else {
echo "There's been a problem: ".mysql_error();
} 2、查询并显示数据$sqlAll = "select * from users";
$result = mysql_query($sqlAll);
$row = mysql_fetch_array($result); //得到记录集的一行,放到数组row中
while ($row) {
echo $row["username"]." -- ".$row["email"]."<br />";
} 第三步:释放并关闭数据库链接@mysql_free_result($result);mysql_close();//执行完后关闭数据库
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>增加用户</title>
<style type="text/css">
<!--
.STYLE1 {
color: #FFFFFF;
font-weight: bold;
}
-->
</style>
</head>
<body>
<?php
if($_POST['submit'])
{
$wyx_name=$_POST['wyx_name'];
$wyx_pass=md5(trim($_POST['wyx_pass1']));
$sql="INSERT INTO wyx_user (wyx_name,wyx_pass) VALUES ('$wyx_name','$wyx_pass')";
$result=mysql_query($sql);
header("Location:admin_user.php");
}
else
{
?>
<form method="post" name="form1" action="<?php echo $PATH_INFO;?>">
<table width="400" border="0" align="center" cellpadding="5" cellspacing="1" bgcolor="#666666">
<tr>
<td colspan="2" align="center" bgcolor="#666666" class="STYLE1">增加新用户</td>
</tr>
<tr>
<td width="150" align="right" bgcolor="#FFFFFF">用户名:</td>
<td width="250" bgcolor="#FFFFFF"><input name="wyx_name" type="text" size="17"/>
<font color=red>*</font></td>
</tr>
<tr>
<td width="150" align="right" bgcolor="#FFFFFF">密码:</td>
<td width="250" bgcolor="#FFFFFF">
<input name="wyx_pass1" type="password" size="18"/> <font color=red>*</font></td>
</tr>
<tr>
<td width="150" align="right" bgcolor="#FFFFFF">重复密码:</td>
<td width="250" bgcolor="#FFFFFF">
<input name="wyx_pass2" type="password" size="18"/> <font color=red>*</font></td>
</tr>
<tr>
<td colspan="2" align="center" bgcolor="#FFFFFF"><input type="submit" name="submit" value="提交" /></td>
</tr>
</table>
</form>
<?php
}
?>
</body>这个没有对两次输入的密码进行验证
连接数据库的代码就不要我写了吧