|
发表于 2015-12-6 12:52:22
|
显示全部楼层
不用这么麻烦 用这个login.php就好了; S9 m4 S/ T, n' A' ~1 z h( M
- 5 P, \/ K/ `; c& e, ~
- <?php
3 w ?) X% F9 f3 u0 X$ E- Q - $error = '';$ `, R( `2 \5 G C$ L
- $_SESSION['imobi_data'] = array('imVersion' => '3.7', 'xmlVersion' => '3.5');
, z5 i3 r# [; e# B - 0 Q- {6 I" k$ l7 o. {3 W1 D
- if ($_SERVER['REQUEST_METHOD'] == 'POST')
6 }" F3 {7 q" E% q X) o - {# G) }; M0 e8 b
- include( 'mt/mt_pconnect.php' );& F U, E5 D8 F6 D, {/ X, e
- include( 'mt/mt_pwd.php' );" q0 U( \1 ]' u4 ~. J5 @4 V/ Z1 f
- $userName = $_POST['userName'];
[" S t" u1 j5 n8 l - $user_password = $_POST['userPassword'];
: h; [- o/ U0 w# } - $loginSql = $db -> prepare('SELECT * FROM mt_account WHERE user_name=:user_name');# ^. T! G) v) H" h" }: d; W
- $loginSql -> bindParam(':user_name', $userName);" \, T! i/ {5 T* |
+ z- _0 A' J9 Z8 Q( L; M- if ($loginSql -> execute())- H1 [! ~! O+ S M; j) E; N" }
- {
2 k8 ]( a5 K1 X1 e3 o - $data = $loginSql -> fetch(PDO :: FETCH_ASSOC);
7 I1 n# U9 O$ d X$ `3 ]. ]2 b7 T - if ($data)
$ ?! y: |+ F t& j4 J) T - {1 P+ `7 y5 `4 T
- $bcrypt = new Bcrypt();3 [0 v% T8 [) R! X4 e. `) q/ t. U
- $isGood = $bcrypt -> verify($user_password, $data['user_password']);
- Y. y) w( e% O7 l" z - if (!$isGood)
7 p2 q6 m* i! J* w" ]' } - { Y# W1 ?4 \5 g! y- a$ @3 D8 ]2 Y$ Z
- $error = 'Your password is incorrect.';
; g6 R7 c7 k& W# L- F( b1 ?9 g - }
, ?* d' z5 |0 a - else0 D5 y+ ^9 S- b- n$ j
- {
: r9 o/ ^: n/ N7 e1 X - $_SESSION['iMobi_sessionTime'] = time();. G) k+ _% ~; n- r1 Q5 `# r# l
- $_SESSION['iMobi_userName'] = $userName;4 k/ O! L" \& F1 p _$ O6 O
- $_SESSION['iMobi_userId'] = $data['user_id'];) Z* j2 g5 q" K' a6 S9 u
- $_SESSION['iMobi_timeout'] = $data['user_timeout'];5 Z. |, W1 h5 L! R8 J
- $_SESSION['iMobi_timezone'] = $data['user_timezone'];9 u( u* s$ K; P6 G1 v2 `% t. r" A9 I: o
- $_SESSION['iMobi_Login'] = true;( |! g4 K) k) x7 S% A6 N9 s! ~. T! Y
5 J" i3 F% l$ p- if (!empty($_SESSION['lastPage']))
. q; S9 I4 X( d - {
. b9 ]3 C( w/ P6 I - $redirect = $_SESSION['lastPage'];
5 y2 }9 V3 ^0 Q6 |1 l# ^ - unset($_SESSION[lastPage]);
) `$ m$ D4 o+ m5 N" A* k - } 3 J: U; [; P+ B7 x! V
- else Q; e# u( _# E! T2 T) P, t3 \0 H
- {& l4 O% {$ E" f f2 S$ ~
- $redirect = 'campaigns.php';
' W, P |, C3 y - } : U- \# |( m0 y d" N
- U8 r) I. X( P- o; `7 \3 _4 [# l
- header('location: ' . $redirect);+ e) H \6 j7 V7 t
- exit();& f# c$ N3 d& A$ T7 X6 x
- } K, y! f6 e( t) `" Y* }
- } * k' |! Z! y% j4 J# {6 R- ]; g
- else
% D* q7 q; i" f+ L7 {/ e( p - {1 J$ ?1 l. s! o* l7 L4 @+ r! O
- $error = 'The username entered is not found.';; M1 F' ~! b2 X4 Q
- }
* P6 Y: \6 d4 A- _ - }: C' x7 x" l+ d
- else; W5 g7 S! ^2 Y! o( A
- {
5 R/ ^8 q' ?2 }9 O, i$ } - $error = $loginSql -> errorCode();& w* d0 V& D% C* F: g9 d# \6 O
- $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);' O4 r/ {8 B3 k& {. Y( W
- }
- Q' w3 n0 E) a. [) ?8 q o - }! J: U- R9 n# ^& _0 H- R. |
- ?>
$ u% O( |" v+ D - <!DOCTYPE html>
7 T1 s" n5 R$ J E/ A - <html>
& _( K2 f% e* d, e8 |' B6 p
: \0 U z) K0 Q8 n: E- Q: v* S- <body>
1 m/ w6 _- \- N _# \) S - ' i c4 ~' }/ \4 m, k; o) ]
- <div id="content">
\! B5 i8 E6 {1 A' Z - <div id="main"># a6 e1 a1 Y0 B) I
- <h1>Login</h1> A$ m4 a+ s" }6 U4 T5 ?
- <?php
1 W3 X3 u$ n, |( V- I- s6 N - if (!empty($error))
) f) ?) Q7 z+ m: o* Y( S$ d. g - {8 t. ^, G" N; {" e1 h
- echo '<div class="error">' . $error . '</div>';
j. b8 z! }) q' _5 F0 x; L" j( ` - }
* X. K9 @6 d y5 S1 i" a. j - ?>$ F( y3 Z E. Y) t" D7 W/ j n
- <div id="login">
7 f' }& H$ H5 y/ A5 C. w! B) E - <form method="post" action="">
3 p. K' Q6 V! P7 K* q - <input type="hidden" name="tokenId" value="605871997">
6 v- y, R/ O5 i- q: N; v. U - <input type="hidden" name="846c3d198c2af4004cdc58e6e5f00468d81bdda4" value="921541f1e1363396dda7d30197ea67593e9f6bcc"># H1 m% x/ h; |: z6 F P3 j
- <table class="login">
) e0 o) |; @8 T7 D8 D, G' R - <tr>
- O/ G2 a9 O% n+ k - <td class="name">Username:</td>. z2 s6 H1 Q7 e0 a0 w
- <td><input id="userName" type="text" name="userName" value=""></td>- J$ R7 ~: z6 T, l- v { @
- </tr>& p3 F$ F+ b& L
- <tr>
& E: f1 J& e, a. w. Y& W - <td class="name">Password:</td>1 m: k0 f) H. u0 W8 A, U# p
- <td>
C. b$ n @! o0 e4 Z5 b* c - <input id="userPassword" type="password" name="userPassword"> ; F+ }& R( O6 B; Z. e. @
- </td>
9 Z6 R" {3 ?; H3 X! P2 E# x - </tr>3 k/ `* n) f0 m: d5 X
- <tr>
# ?3 b! n: A/ `$ b" v - <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>
5 y- U( Y2 D7 p, S5 v2 w4 U1 s - </tr>
1 F8 b4 h3 o% c d - </table>
7 F i7 v% m D - </form>7 M6 T/ S4 x/ G
- </div>
+ `% x5 }) r5 F' Z9 R* ^ - </div>
" @' T" D* t3 ~" C* I: s* y7 P- u - </div>
0 A: k1 b6 O& Z! L - ) ?8 u' ~2 `6 Y2 S) B: }4 @: k
- </body>, k$ H _7 m$ T& E# i4 a
- </html>
& c4 D9 o% R# E; z$ `* B
复制代码 |
|