|
|
发表于 2015-12-6 12:52:22
|
显示全部楼层
不用这么麻烦 用这个login.php就好了
/ \4 r) k2 a q# |6 c- 2 R# [) _9 v9 {9 r
- <?php' R' ^+ n; V8 A
- $error = '';8 E& K( _4 [2 _( |* V/ C1 g
- $_SESSION['imobi_data'] = array('imVersion' => '3.7', 'xmlVersion' => '3.5');9 e. t- s' V9 S& w' C
- % o7 C$ s) H- s7 E8 t; {9 D
- if ($_SERVER['REQUEST_METHOD'] == 'POST')0 H$ o- v! X# j3 }9 k# K5 H
- {8 R8 {. Q& e5 p' {
- include( 'mt/mt_pconnect.php' );
& H5 W: u5 `6 _/ D) I z- g l - include( 'mt/mt_pwd.php' );
( n4 q5 y" g# o9 w5 ` - $userName = $_POST['userName'];
) }3 b) I2 ]& l3 G8 b( B/ C' h2 P2 B - $user_password = $_POST['userPassword'];
8 W, b( i! f; Y' V- _) L+ R - $loginSql = $db -> prepare('SELECT * FROM mt_account WHERE user_name=:user_name');
+ c V; m% O! ]; h8 q( p4 y - $loginSql -> bindParam(':user_name', $userName);' D2 c) Q2 [& A3 H3 h# z
! z0 i+ w5 o$ s" ]1 N1 ^- U- if ($loginSql -> execute())5 u3 h/ p- F6 b- U3 y1 _. Y2 \
- {" c' [, o( h( \% L( x' l
- $data = $loginSql -> fetch(PDO :: FETCH_ASSOC);, `) {* k3 O: V- r
- if ($data), j# G# ]+ b2 L$ }3 }4 F
- {
( {# A: s' l. n y) a3 k; U - $bcrypt = new Bcrypt();
! R% u, A1 U+ f* l, _ - $isGood = $bcrypt -> verify($user_password, $data['user_password']);; v5 K2 ^- C7 ^
- if (!$isGood)3 t( V. N0 c) o3 g) ^
- {
2 o. h% O1 d5 @* x6 h - $error = 'Your password is incorrect.';
. k; ~) L+ d% A( Q* k4 S9 o - }
; Y9 R1 h' [0 A/ p - else
, ~# d9 q2 d6 q0 N2 V/ C, L - { K. i. A8 q/ q
- $_SESSION['iMobi_sessionTime'] = time();
& W0 [- B1 G2 @; N9 D - $_SESSION['iMobi_userName'] = $userName;8 K) a3 @4 L7 h) i( M7 L
- $_SESSION['iMobi_userId'] = $data['user_id'];
, [ h$ m/ G% P! v" @% v+ e+ [ - $_SESSION['iMobi_timeout'] = $data['user_timeout'];
. p3 u' r {6 D# n - $_SESSION['iMobi_timezone'] = $data['user_timezone'];
8 z0 y& `. u% o5 x0 K( q5 ^ - $_SESSION['iMobi_Login'] = true;
/ y) w9 D/ `* q4 t4 x - 5 K+ K6 |8 o9 x0 f, n
- if (!empty($_SESSION['lastPage']))
8 h! Y$ N( @$ x6 z, d3 J - {0 G {, H$ K1 ~5 n$ w
- $redirect = $_SESSION['lastPage'];
7 N7 V) \/ R2 M7 \ - unset($_SESSION[lastPage]);; z, A4 W" ?, r
- } / x9 c' `8 S3 E* J! x
- else. u% p4 w E4 p/ P
- {
& q: u- j5 H7 S; g - $redirect = 'campaigns.php';( h' e- n5 s i- g# V
- }
7 Z) w4 }% j u3 u- f - ) t8 A5 E* q! }$ ~7 h' ]' C7 F4 p
- header('location: ' . $redirect);/ a- ]. e- P) j
- exit();$ V! k! M+ V: s7 @, |% z# \) c
- }
9 ]+ b' n/ Y2 v) g - } , W" P3 U7 P- O" q
- else
% t5 i5 R" }- c3 K: b - {/ Z6 N- O2 z8 ~
- $error = 'The username entered is not found.';
7 V' ?/ C) g. f5 r: `3 q! d0 S - }
; l x! q9 L) J7 L& W) f+ Q- N - }' ^! g$ R- u$ ]5 H. m1 T& N
- else
; X/ J3 M( C5 S2 [" e. _& K& \ - {9 {$ S* w2 r: @- g8 q: A
- $error = $loginSql -> errorCode();0 g/ i$ X& B3 ?+ ]/ j3 ~9 m
- $error = ($error == '3D000' ? 'Database Connection Error: (DATABASE NOT DEFINED) - The database in mt/mt_config.php is blank. Enter a database name in mt/mt_config.php to connect to the database.<br><br>(Also, be sure the correct databse user name and password are entered in mt/mt_config.php)' : 'Error Code - ' . $error);) |/ J. b: @0 Z: Q8 U* X8 ~
- }
/ w" H) j% n" E8 U* o - } A$ t! c* J3 P+ d7 z9 ~- ^
- ?>
* o9 j7 C0 o6 m8 T3 _4 b% r - <!DOCTYPE html>
5 _5 ]+ y2 ~# l - <html>
: K# ?2 V; f1 g: S8 V5 Y2 B5 e
; t( |' K1 Z8 Y4 s$ s! E- <body>4 ~3 M4 P5 f% O! S. L
" G% ^6 W& \$ d" d; Y& m- <div id="content">
& P# @0 i1 k; ^. B* O - <div id="main">6 m9 y0 b k! o& Z1 t/ m
- <h1>Login</h1>
* |/ G2 b4 |/ _2 ? - <?php
; l1 `: U% Q7 _7 K9 x# ^) f% { - if (!empty($error))9 W2 P& [+ g- ]
- {1 r# Z! z+ r! }- Z6 h% p, K
- echo '<div class="error">' . $error . '</div>';0 Z% T( @7 q7 p8 N1 E, Q
- }! p/ Q. ?2 r# Q i8 ?
- ?>
3 a* l2 c1 m0 v1 T9 x - <div id="login">
$ `. e x7 V+ n, a2 D" ] - <form method="post" action=""># a M# M- a5 K6 p6 L
- <input type="hidden" name="tokenId" value="605871997">3 q, m7 |) e( V
- <input type="hidden" name="846c3d198c2af4004cdc58e6e5f00468d81bdda4" value="921541f1e1363396dda7d30197ea67593e9f6bcc">
" M" j# u. `8 S# u) Q, k - <table class="login">/ K, {5 B/ x& q! j# u8 S8 Y% a, s
- <tr>7 A( h, W/ ~! j; P( I% X5 x8 a7 Y
- <td class="name">Username:</td>
/ D3 U, Y) ?; w! e - <td><input id="userName" type="text" name="userName" value=""></td>
* }5 A2 ]( A. i2 S* P3 x - </tr>8 H) y/ j% ^7 w8 H7 d# c8 L
- <tr>
- q7 q; S3 `% V; _ - <td class="name">Password:</td>
$ Y* `" {, M' U# {& R. ?$ T - <td>) q/ \# c" k+ ?- |
- <input id="userPassword" type="password" name="userPassword">
0 O* ~/ V/ ~! O# |, ^ - </td>
4 L0 j/ @( s, T% _) G2 k - </tr>
! r) N2 M* H6 a! G, e6 ? - <tr>0 V; R" |/ N# Y
- <td colspan="2" style="text-align:center"><input id="submit" style="margin:5px 0 0 0" class="submit_btn" type="submit" value="Sign In"></td>
& |* n# z& q5 ~8 O% g- e) N - </tr>
5 L' m$ f* d/ x- X- o2 w: E: t3 _9 k - </table>$ e9 Y1 }7 ]1 E8 K
- </form>
# I6 E2 O; p; C# W - </div>
2 F0 t" P/ ^0 w' }; E) x - </div>; B& |! b2 K" |0 l' ~8 m
- </div>
; a5 K- W# e; c# U& m; D( x - ) T( d2 y! Z/ B9 u
- </body> i8 t' ?: D7 v5 |# q3 s
- </html>7 C1 o4 q3 J. \# D, f
复制代码 |
|