Delimiter // Create procedure insertuser(in username varchar(20),in userpwd varchar(32)) Begin Insert into welefen.user(Name,Pwd) values (username,md5(userpwd)); End // 验证用户的存储过程,代码如下:
Delimiter // Create procedure validateuser(in username varchar(20),out param1) Begin Select Pwd into param1 from welefen.user where Name=username; End // 修改密码的存储过程,代码如下:
Delimiter // Create procedure modifyPwd(in username varchar(20),in userpwd varchar(32)) Begin Update welefen.user set Pwd=md5(userpwd) where Name=username; End // 删除用户的存储过程,代码如下:
Delimiter // Create procedure deleteuser(in username varchar(20)) Begin delete from welefen.user where Name=username; End // 在客户端,我们给出如下的程序,代码如下:
<?php if (!mysql_connect("localhost","root","welefen")){ echo "连接数据库失败"; } if (!mysql_select_db("welefen")){ echo "选择数据库表失败<br>"; }