|
发表于 2015-12-6 12:52:22
|
显示全部楼层
不用这么麻烦 用这个login.php就好了
9 P/ K; @. k6 i. _$ U7 Z2 g- |- ' o- t0 M9 x" K( B
- <?php
; x7 x( d' Q, s, V - $error = '';
; s# n- K, W$ e6 v% W# N( c - $_SESSION['imobi_data'] = array('imVersion' => '3.7', 'xmlVersion' => '3.5');* H. h0 \7 B1 E; E* w
- 9 W! M# e: r' H# M- s' e
- if ($_SERVER['REQUEST_METHOD'] == 'POST')1 \* } J T! o" n) j4 G+ d
- {
& u4 P: y9 `. h& T - include( 'mt/mt_pconnect.php' );1 k* k& z- Y$ c% z, {6 p
- include( 'mt/mt_pwd.php' );6 T) P4 ]) v! i1 n
- $userName = $_POST['userName'];
3 g" ]- K# r- K" ^ - $user_password = $_POST['userPassword'];9 F2 r. ^ b% q% g- h: d" S* u3 t; `! Q
- $loginSql = $db -> prepare('SELECT * FROM mt_account WHERE user_name=:user_name');6 v3 u' r7 k9 `! u. v
- $loginSql -> bindParam(':user_name', $userName);
% `% z; l" q0 `$ u8 e% i$ @
, A+ l( }) ?* {+ i% t8 v- if ($loginSql -> execute())
6 T( i P9 K$ K$ V | - {
% d' N2 [ z) V2 a6 `5 s - $data = $loginSql -> fetch(PDO :: FETCH_ASSOC);
% `, R3 x0 C B) h( i - if ($data)9 b r$ c- z- X4 c! K1 K" r' l9 \
- {
" R$ e- J7 @& f$ ]3 Y - $bcrypt = new Bcrypt();
/ i6 n0 k# J6 Q X0 ?- u - $isGood = $bcrypt -> verify($user_password, $data['user_password']);
0 C4 G+ w" j2 S6 E, o+ G4 p- |: e - if (!$isGood)
2 v( U$ J& Z& u - {3 N+ _( u' Z6 U! S3 c6 m, A
- $error = 'Your password is incorrect.';
. b' ^& M# L* t4 \4 f% i( q - } 3 b* D4 O: U, c; m- B( J0 p. z
- else) g4 V- f h# l- N
- {* {3 t/ ~- p# K7 @- S
- $_SESSION['iMobi_sessionTime'] = time();
; U. x/ x1 A( Y/ U* ?" E - $_SESSION['iMobi_userName'] = $userName;
' F6 ]- D2 x% K2 i' |0 q* A - $_SESSION['iMobi_userId'] = $data['user_id'];
- P. K6 x! H* N9 k/ D1 J: x& @ - $_SESSION['iMobi_timeout'] = $data['user_timeout'];
6 X* A5 {6 e. m% ]7 S" y7 `% W/ y0 N - $_SESSION['iMobi_timezone'] = $data['user_timezone'];
# l7 y* `) G) u) ^" ]7 U - $_SESSION['iMobi_Login'] = true;' F% J- z9 J0 X" D4 |
. W+ m9 V. W4 G1 X% B2 M+ m- if (!empty($_SESSION['lastPage'])), a B/ C. {/ K& D
- {
# E0 ^* n* H* v7 C: g - $redirect = $_SESSION['lastPage'];
! M* q3 D; o9 V - unset($_SESSION[lastPage]);2 O' E* X/ y# S2 j. |
- } - t- A" w2 d$ E; N* M* ]
- else
" G/ K- G6 W+ f" p' `. V - {7 D0 P5 ?9 h* W" a* G* K
- $redirect = 'campaigns.php';( v$ I7 ^5 d j: l+ o- n& M
- }
! J4 d; t" b% E o/ G* Y - 0 F3 x4 y* N* I- Y, D
- header('location: ' . $redirect);
3 P) q+ U: m8 D; ?; g3 n5 [ - exit();
% ]6 }- M' h8 i: q9 x - }
! v, K3 a" s+ t* P3 z6 n1 ` - }
% K) j, I* G Q% K5 S& x - else0 I( j% f$ d. G7 `$ P }
- {
3 D' L7 y# j" P+ T) e! h% Z% R - $error = 'The username entered is not found.';
: P( u9 E) O# E3 P! J: Z: | - }
& H s) @0 H: X+ R* N# P - }9 D- q" ]# k, A1 z
- else
0 T7 `/ l- g) z# w - {
- Z3 G5 J( A5 ^9 e A+ O/ y - $error = $loginSql -> errorCode();) F; f5 g$ S. b0 q# ^2 F
- $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);
8 g# ]2 B- W4 D, R: ` - }: [+ n: U+ E- H5 v+ i7 n& A2 I
- }
# W5 @& f% T- Y+ K8 ^3 O - ?>/ @3 W% H: t, a5 Y2 [! D* k
- <!DOCTYPE html>
2 Y9 q8 t) [) y! G" C - <html>
" E" Q" I: [, i4 L% F - $ o) Q( b% {5 v1 p6 y3 [
- <body>
" N1 ~5 l' g3 Q& o8 Z
0 ^' x/ i! j' M$ \- <div id="content">" |4 ]6 S) l9 v4 h' ?; z: ~8 o
- <div id="main">( d& T3 Z$ C4 d- _% l
- <h1>Login</h1># O; v1 N- P$ Q( W! Y
- <?php6 f* O( }& Q; ] y
- if (!empty($error))
6 W- Q3 \6 D1 w. Z9 w - {
- X$ W5 ]6 i+ e4 O1 i& M- R1 E& k - echo '<div class="error">' . $error . '</div>';* @' Q- r& N. J1 ~# |/ a! p
- }
. D3 e& G0 w; r& v( V1 T - ?>
& K! V# r) x( q# ?- ? - <div id="login">( v7 n5 T' ]) K7 T" ^$ ]
- <form method="post" action="">( D3 @- K1 S# M" J, F5 \9 a; `
- <input type="hidden" name="tokenId" value="605871997">
2 b' m8 V- n- C! U) x( F - <input type="hidden" name="846c3d198c2af4004cdc58e6e5f00468d81bdda4" value="921541f1e1363396dda7d30197ea67593e9f6bcc">; g6 T+ B, l+ ]& H9 ?6 m
- <table class="login">
i, o6 z0 o$ e& K1 l - <tr>/ L2 m& r8 P+ c" l' G
- <td class="name">Username:</td>
5 d! T: P: u& g. R6 h) k - <td><input id="userName" type="text" name="userName" value=""></td>" A' U! x6 s- Z6 a+ l
- </tr>7 o8 S K! Z6 [
- <tr>
2 \& A$ q9 g% k8 |1 o - <td class="name">Password:</td>
9 c d2 O2 X8 Y& v' y* c - <td>
* w( i% S. E/ i- J1 B3 ` - <input id="userPassword" type="password" name="userPassword">
: V; y4 f, h9 y6 h5 K1 B" w8 ~3 h3 u0 N - </td>
+ l# E0 `& {( l' b1 Q - </tr>& K* r4 ]8 w; D W, L1 J) G6 I
- <tr>9 Z* U* e) m5 V6 ]7 g) }" |
- <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>8 L5 X' W- R- G. d4 z0 N' d
- </tr>9 T# @& H5 E1 K- V) D- M9 s
- </table>
- ?8 @& J) }2 v& v - </form>
, a0 H& N, u3 ^9 M - </div># x# `/ f/ L- A( I6 B; z; D2 i! b
- </div>3 t; I! ^1 I) P. z# u
- </div>/ t2 j& j. Y% ]
7 U+ P) g" ^' Z6 l5 y: l- </body>* S/ @* o) i4 Q4 e" m1 V8 L3 f
- </html>, h" m- |. P7 _/ ^, F
复制代码 |
|