|
发表于 2015-12-6 12:52:22
|
显示全部楼层
不用这么麻烦 用这个login.php就好了% ^$ Y$ c F: L: a
+ J' n/ W) S$ f0 H( B4 D e- <?php
4 [5 g, \! ~- ^9 \" w - $error = '';* a& [1 Q# Z+ t; `( g% D
- $_SESSION['imobi_data'] = array('imVersion' => '3.7', 'xmlVersion' => '3.5');
& M0 i# o9 ?0 H2 P" H3 Z/ X+ v1 V+ b1 u
/ E# p2 Q5 r; @% u) X6 I' Y- if ($_SERVER['REQUEST_METHOD'] == 'POST')' G/ F! q% b6 f" q; Q4 W
- {, O4 |' H& g5 Y# |
- include( 'mt/mt_pconnect.php' );& Y* |6 j# ~4 I6 K
- include( 'mt/mt_pwd.php' );
4 X8 i& k& v: J+ v$ u - $userName = $_POST['userName'];8 }* m. ~) X& o
- $user_password = $_POST['userPassword'];
; p2 O8 r F$ D6 a4 H; m - $loginSql = $db -> prepare('SELECT * FROM mt_account WHERE user_name=:user_name');
$ B1 |. X1 b" s1 v) g4 n9 s$ C - $loginSql -> bindParam(':user_name', $userName);
* J( b9 ^ i2 U. ?; `3 n
2 |" b# o. v, _4 _( N+ a- if ($loginSql -> execute())2 l* P: C6 ?8 N0 G
- {4 R, }6 k8 }6 E A C
- $data = $loginSql -> fetch(PDO :: FETCH_ASSOC);/ a( b+ c. E& Q0 z) T
- if ($data)4 n) N7 c- E/ [/ ~) s
- {
* k0 p0 X8 Y1 I2 ] - $bcrypt = new Bcrypt();4 q$ @2 k- ]% m3 P
- $isGood = $bcrypt -> verify($user_password, $data['user_password']);
- y/ {6 h) i# Y9 K! m- }8 [' T - if (!$isGood)- @2 o2 P: b( [8 x) K2 X
- {, H0 V5 r0 @( N6 K% N
- $error = 'Your password is incorrect.';8 c, V1 b- ^5 k$ l" d# w
- } 9 R1 j3 ]" e- D6 r5 T3 q# X
- else
8 h/ P) p1 I7 Z0 X% x5 K$ d - {
/ U* N2 I& \. B% c. p# H/ l) V- h - $_SESSION['iMobi_sessionTime'] = time();
/ {# K7 L$ S) C2 b& P) w* E - $_SESSION['iMobi_userName'] = $userName;
7 A0 {" ^; S" H$ e: I - $_SESSION['iMobi_userId'] = $data['user_id'];% @' t, g, q" l7 Z* U& h
- $_SESSION['iMobi_timeout'] = $data['user_timeout'];' P2 }& A7 q1 }
- $_SESSION['iMobi_timezone'] = $data['user_timezone'];
' q9 h: K2 J3 X h: M5 G. f - $_SESSION['iMobi_Login'] = true;
: O; v) f9 k' P/ Y7 E1 F8 Y
+ H7 ~3 A' f" \- if (!empty($_SESSION['lastPage']))
~& ]/ ^; X5 d, J; c/ s - {
0 B/ V# b- u7 S8 Q }! ^ - $redirect = $_SESSION['lastPage'];
1 G4 I* d! u/ s9 u5 f1 E8 T - unset($_SESSION[lastPage]);+ q( }8 E1 Y# ]2 L, p
- }
! S) w; V) x2 _9 G - else2 @4 a( O9 e1 h. K' E
- {# L5 f/ w. y. n1 d ^! D
- $redirect = 'campaigns.php';/ H5 N2 b6 g/ G/ y" x5 J7 f
- } : R) k# i7 ?( Z% W4 j) E3 E
- ' A+ G& C5 n. Z$ y2 H) ^
- header('location: ' . $redirect);
2 B& u. _2 |' ?( R# z! A - exit();1 U& `7 X6 k3 G; b. ]3 ?
- } - P r7 p; e, P: o U+ I1 U
- } / X& V4 F3 P& X5 ]0 v0 i
- else, o. v, d$ z; c; f, }# w
- {% r# b) Z3 a5 N! U
- $error = 'The username entered is not found.';- P4 y: N, U1 Y% m7 G" D' X4 S; j
- }$ q& ]- G) Q1 m6 L3 V4 M
- }1 T8 D4 j' X k
- else
7 Z! d( e6 L# l O. s( ]3 c - {" i: u1 Q% K6 w
- $error = $loginSql -> errorCode();2 X7 C V# F, L2 s6 S# v
- $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);
3 ~$ Y( _4 t$ g - }
# w6 c. S) l: R5 m7 s9 P7 Q/ k ~. k - }
) J# u* y# L% H- [9 O) ^) S( A - ?>5 ~: |2 P y: N7 x7 j; d
- <!DOCTYPE html>
2 A! |/ e/ U9 B) Q2 f5 f( g" B - <html>
+ G' L# \0 G/ D
' k0 b* O& @3 \! ]/ p# D* e& }- <body>
, l1 e- [6 T) c# c - - g# {7 ?4 R/ H0 q/ t
- <div id="content">
7 Z1 L9 P/ Y4 N1 w" Y% {7 M+ ~: ~9 }! I - <div id="main">/ ?1 n [6 ?/ D3 s1 R
- <h1>Login</h1>2 @8 _' Q! Y- l% H, X* E
- <?php; b5 p$ v6 Q$ P$ ]4 N0 f
- if (!empty($error))1 j# ~7 S! M# ?! O& ~
- {. h2 z+ N. f. P# k5 C4 @
- echo '<div class="error">' . $error . '</div>';
+ m6 F, ?* e; [: m3 w" T - }# I+ a8 F3 b# l% m" r( [$ g
- ?>
& t. u2 i. i0 u6 k/ l$ n4 F - <div id="login">$ z# j T3 |" l/ G: Z
- <form method="post" action="">
O! Y+ L- D& x! @2 E4 A3 y/ A1 Z, c# p - <input type="hidden" name="tokenId" value="605871997">
2 r8 ]0 q- h2 m' l% P7 @# z" [ - <input type="hidden" name="846c3d198c2af4004cdc58e6e5f00468d81bdda4" value="921541f1e1363396dda7d30197ea67593e9f6bcc">) O& ?/ ]1 E8 h% J( ^) Z+ A |
- <table class="login">, A1 \8 R; ]6 m; t5 Z, g
- <tr>& x; D5 O5 z5 X' C; g7 @
- <td class="name">Username:</td>
$ D. d. R+ j% F - <td><input id="userName" type="text" name="userName" value=""></td>0 W$ { _% P7 K& R
- </tr>
! ^) Z8 I0 c. q+ k& e" z& | - <tr>
4 T$ |9 K6 X% _ - <td class="name">Password:</td>
5 ]% ~8 j/ @$ l4 e - <td>9 |7 h' V4 u8 z- ^( p
- <input id="userPassword" type="password" name="userPassword">
4 v' U7 F8 F6 |: S' r V - </td>
2 @% f# H* z, l - </tr>$ Q" O* N% D9 L1 Y& r
- <tr>
" E/ C( }. D! S1 d5 \ - <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>3 I' N$ H4 J2 d; d# Y. D {
- </tr>
# ]7 v+ \0 P0 i/ ` - </table>& y+ @+ m# w' z) g S
- </form>* D7 E7 k, K: g5 S1 e6 i) ?
- </div>
% ~; l( c, A* n3 ~6 j9 i+ S - </div>5 O" t1 D: n, q0 u& o4 d. {+ R& n
- </div>( t# m' ]- Q5 {9 S5 k
- 0 a- K5 r$ C7 O6 q2 }( v& A0 y( |
- </body>
& b9 O4 H. {6 F: }' h - </html>/ X7 F1 [) N$ K4 ]
复制代码 |
|