Commit 7b0367f55e54996aa035882c49e166e5fbcb46ca

Authored by luoyanshou
1 parent 435ca67f

【留言板】添加用户登录,添加登录验证

trunk/Message/Api/Controller/Message/MessListController.class.php 0 → 100644
  1 +<?php
  2 +/**
  3 + * Created by PhpStorm.
  4 + * User: Dell
  5 + * Date: 2018/9/4
  6 + * Time: 15:39
  7 + */
  8 +
  9 +namespace Api\Controller\Message;
  10 +
  11 +
  12 +class MessListController extends \Api\Controller\AbstractController
  13 +{
  14 +
  15 + protected $_require_login = false;
  16 +
  17 + /**
  18 + * 构造方法
  19 + */
  20 + public function getList_post()
  21 + {
  22 + $this->_result = '留言列表';
  23 + }
  24 +}
trunk/Message/Api/Controller/User/UserLoginController.class.php 0 → 100644
  1 +<?php
  2 +
  3 +/**
  4 + * Created by PhpStorm.
  5 + * User: Dell
  6 + * Date: 2018/9/4
  7 + * Time: 14:09
  8 + */
  9 +
  10 +namespace Api\Controller\User;
  11 +
  12 +use Common\Model\LuoyanshouModel as UserModel;
  13 +
  14 +
  15 +class UserLoginController extends \Api\Controller\AbstractController
  16 +{
  17 + protected $_require_login = false;
  18 +
  19 + public function Login_post()
  20 + {
  21 + $postData = I('post.');
  22 + $conds = [
  23 + 'u_name' => $postData['name'],
  24 + 'u_pwd' => md5( $postData['pwd'] )
  25 + ];
  26 + $userModel = new UserModel();
  27 +
  28 + $total = $userModel->count_by_conds( $conds );
  29 + $login_flg = ( $total == 1) ? true : false;
  30 +
  31 + $this->_result = [
  32 + 'login_flg' => $login_flg
  33 + ];
  34 +
  35 + }
  36 +
  37 +}
  38 +
trunk/Message/Common/Model/AbstractModel.class.php
@@ -32,12 +32,12 @@ abstract class AbstractModel extends \Com\Model @@ -32,12 +32,12 @@ abstract class AbstractModel extends \Com\Model
32 public function __construct() 32 public function __construct()
33 { 33 {
34 parent::__construct(); 34 parent::__construct();
35 - $this->_tb_arctic = cfg('DB_PREFIX') . 'article'; 35 + /*$this->_tb_arctic = cfg('DB_PREFIX') . 'article';
36 $this->_tb_attach = cfg('DB_PREFIX') . 'attach'; 36 $this->_tb_attach = cfg('DB_PREFIX') . 'attach';
37 $this->_tb_class = cfg('DB_PREFIX') . 'class'; 37 $this->_tb_class = cfg('DB_PREFIX') . 'class';
38 $this->_tb_like = cfg('DB_PREFIX') . 'like'; 38 $this->_tb_like = cfg('DB_PREFIX') . 'like';
39 $this->_tb_read = cfg('DB_PREFIX') . 'read'; 39 $this->_tb_read = cfg('DB_PREFIX') . 'read';
40 $this->_tb_right = cfg('DB_PREFIX') . 'right'; 40 $this->_tb_right = cfg('DB_PREFIX') . 'right';
41 - $this->_tb_favorite = cfg('DB_PREFIX') . 'favorite'; 41 + $this->_tb_favorite = cfg('DB_PREFIX') . 'favorite';*/
42 } 42 }
43 } 43 }
trunk/Message/Common/Model/LuoYanshouModel.class.php 0 → 100644
  1 +<?php
  2 +/**
  3 + * Created by PhpStorm.
  4 + * User: Dell
  5 + * Date: 2018/9/4
  6 + * Time: 14:49
  7 + */
  8 +
  9 +namespace Common\Model;
  10 +
  11 +use Common\Common\Constant;
  12 +
  13 +class LuoyanshouModel extends AbstractModel
  14 +{
  15 + /*
  16 + * 构造函数
  17 + */
  18 + public function __construct()
  19 + {
  20 + parent::__construct();
  21 + }
  22 +}
  23 +
  24 +
trunk/Message/Common/Sql/structure.php
@@ -5,9 +5,10 @@ @@ -5,9 +5,10 @@
5 * $Author$ 5 * $Author$
6 */ 6 */
7 return " 7 return "
8 -CREATE TABLE IF NOT EXISTS luoyanshou( 8 +CREATE TABLE IF NOT EXISTS luoyanshou_luoyanshou(
9 u_id INT UNSIGNED NOT NULL auto_increment COMMENT '用户ID', 9 u_id INT UNSIGNED NOT NULL auto_increment COMMENT '用户ID',
10 u_name VARCHAR(15) NOT NULL DEFAULT '姓名'COMMENT '用户名', 10 u_name VARCHAR(15) NOT NULL DEFAULT '姓名'COMMENT '用户名',
  11 +u_pwd VARCHAR(32) DEFAULT '' COMMENT '用户密码',
11 u_sex TINYINT UNSIGNED DEFAULT 0 COMMENT '用户性别', 12 u_sex TINYINT UNSIGNED DEFAULT 0 COMMENT '用户性别',
12 u_mail VARCHAR(50) NULL COMMENT '邮箱', 13 u_mail VARCHAR(50) NULL COMMENT '邮箱',
13 u_tel VARCHAR(11) NULL COMMENT '电话', 14 u_tel VARCHAR(11) NULL COMMENT '电话',
trunk/www/apidocassets/css/mess_front.css
@@ -4,16 +4,16 @@ @@ -4,16 +4,16 @@
4 } 4 }
5 html, 5 html,
6 body{ 6 body{
7 - width:100%; 7 + width:90%;
8 } 8 }
9 .con{ 9 .con{
10 width: 60%; 10 width: 60%;
11 padding-top: 20px; 11 padding-top: 20px;
12 - margin: 30px auto; 12 + margin: 20px auto;
13 text-align: center; 13 text-align: center;
14 } 14 }
15 -.con>table{  
16 - width: 50%; 15 +.con table{
  16 + width: 70%;
17 margin: 0 auto; 17 margin: 0 auto;
18 } 18 }
19 .con table tr{ 19 .con table tr{
trunk/www/apidocassets/javascript/mess_front.js
@@ -3,16 +3,52 @@ @@ -3,16 +3,52 @@
3 */ 3 */
4 4
5 /** 5 /**
6 - * 留言数据验证 6 + * 数据验证
  7 + * @param src 场景
  8 + * @returns {boolean}
7 */ 9 */
8 -function inputCheck(){ 10 +function inputCheck( src )
  11 +{
  12 + // 发表留言场景
  13 + if( src == 'mess' ){}
9 14
  15 + // 登录场景
  16 + if( src == 'login' ){
  17 + var name = $('#txtName').val();
  18 + var pwd = $('#txtPwd').val();
  19 + if( name == '' || pwd == '' ){
  20 + return false;
  21 + }
  22 + }
  23 +
  24 + return true;
10 } 25 }
11 26
  27 +
12 /** 28 /**
13 * 留言信息提交 29 * 留言信息提交
  30 + * @returns {boolean}
  31 + */
  32 +function jumpSubmit()
  33 +{
  34 + if( !inputCheck('mess') ){
  35 + return false;
  36 + }
  37 +
  38 +}
  39 +
  40 +/**
  41 + * 用户登录提交
  42 + * @returns {boolean}
14 */ 43 */
15 -function jumpSubmit(){  
16 - alert(235); 44 +function jumpLogin()
  45 +{
  46 +
  47 + if( !inputCheck('login') ){
  48 + return false;
  49 + }
  50 +
  51 + $('#frm_login').submit();
  52 +
17 } 53 }
18 54
trunk/www/mess_front/input.PHP
@@ -16,7 +16,7 @@ @@ -16,7 +16,7 @@
16 </head> 16 </head>
17 <body> 17 <body>
18 <div class="con"> 18 <div class="con">
19 - <form action="http://lys.com/wx5019b9c455ea9c81/Message/Api/Message/MessInput" method="post" name="input_frm"> 19 + <form action="http://lys.com/wx5019b9c455ea9c81/Message/Api/Message/MessInput" method="post" id="frm_input">
20 <table> 20 <table>
21 <caption><h2>发表留言</h2></caption> 21 <caption><h2>发表留言</h2></caption>
22 <tr> 22 <tr>
@@ -34,7 +34,7 @@ @@ -34,7 +34,7 @@
34 <tr> 34 <tr>
35 <td>留言内容:</td> 35 <td>留言内容:</td>
36 <td> 36 <td>
37 - <textarea rows="8" cols="50" name="txtCon" id="txtCon" ></textarea> 37 + <textarea rows="8" cols="40" name="txtCon" id="txtCon" ></textarea>
38 </td> 38 </td>
39 </tr> 39 </tr>
40 <tr> 40 <tr>
trunk/www/mess_front/login.php
@@ -3,35 +3,36 @@ @@ -3,35 +3,36 @@
3 <head> 3 <head>
4 <meta charset="UTF-8"> 4 <meta charset="UTF-8">
5 <title>用户登录</title> 5 <title>用户登录</title>
6 - <link href="../apidocassets/css/mess_front.css" > 6 + <link type="text/css" rel="stylesheet" href="../apidocassets/css/mess_front.css" />
  7 + <script type="text/javascript" src="../apidocassets/javascript/jquery.min.js" ></script>
  8 + <script type="text/javascript" src="../apidocassets/javascript/mess_front.js" ></script>
7 </head> 9 </head>
8 <body> 10 <body>
9 <div class="con"> 11 <div class="con">
10 - 12 + <form action="http://lys.com/wx5019b9c455ea9c81/Message/Api/User/UserLogin/Login" method="post" id="frm_login">
11 <table> 13 <table>
  14 + <caption><h2>用户登录</h2></caption>
12 <tr> 15 <tr>
13 <td>用户名:</td> 16 <td>用户名:</td>
14 <td> 17 <td>
15 - <input type="text" name="txtName" > 18 + <input type="text" name="name" id="txtName" >
16 </td> 19 </td>
17 </tr> 20 </tr>
18 <tr> 21 <tr>
19 <td>密码:</td> 22 <td>密码:</td>
20 <td> 23 <td>
21 - <input type="password" name="txtPwd" > 24 + <input type="password" name="pwd" id="txtPwd" >
22 </td> 25 </td>
23 </tr> 26 </tr>
24 <tr> 27 <tr>
25 - <td colspan="2">  
26 - <input type="submit" value="登录" style="padding: 10px 20px;" > 28 + <td colspan="2" style="text-align: center;">
  29 + <input type="button" value="登录" onclick="javascript:jumpLogin();" style="padding: 10px 20px;" >
27 </td> 30 </td>
28 </tr> 31 </tr>
29 </table> 32 </table>
30 - 33 + </form>
31 </div> 34 </div>
32 </body> 35 </body>
33 </html> 36 </html>
34 37
35 -<?php  
36 -  
37 38