码迷,mamicode.com
首页 > 其他好文 > 详细

redis 简单的注册

时间:2017-06-06 23:40:09      阅读:309      评论:0      收藏:0      [点我收藏+]

标签:user   style   uname   log   code   redis   pwd   php   method   

首页写一个页面

<form method="post" action="hreg.php">
      Name:<input type="text" name="uname" /><br>
      Pwd:<input type="text" name="upwd" /><br>
      Age:<input type="text" name="uage" /><br>
      <input type="submit" text="注册">
</form>

然后写php的注册代码:

<?php
  $redis=new Redis();
  $redis->connect("127.0.0.1",6379);
  
  $name=$_POST["uname"];
  $pwd=$_POST["upwd"];
  $age=$_POST["uage"];

  
  $id=$redis->incr("id"); //自增的id,如果有就加一,没有就是1

  $redis->hmset("user:".$id,array("name"=>$name,"pwd"=>$pwd,"age"=>$age));
  
  print_r($redis->hgetall("user:".$id)) ;
  
  
?>

 

redis 简单的注册

标签:user   style   uname   log   code   redis   pwd   php   method   

原文地址:http://www.cnblogs.com/hometown/p/6953875.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!