|
发表于 2015-12-6 12:52:22
|
显示全部楼层
不用这么麻烦 用这个login.php就好了
9 r4 A' P/ J. [4 g/ y6 v- 7 F. `; H# @9 Q& i
- <?php
3 z3 q' ^3 W0 C" x9 l7 d - $error = '';
( w7 ^6 \, c* f. R8 h/ Y - $_SESSION['imobi_data'] = array('imVersion' => '3.7', 'xmlVersion' => '3.5');
/ X. v6 `' q% K# j0 ?: \
7 k; K. R+ F; V @- if ($_SERVER['REQUEST_METHOD'] == 'POST')
4 i1 F0 ]) k( N9 d6 Z( Q1 X - {& ?: L/ S3 v/ {; y# X& w" D+ V0 M0 `
- include( 'mt/mt_pconnect.php' );" f3 D2 G( [7 U
- include( 'mt/mt_pwd.php' );0 R$ B4 s7 X) A/ z7 N
- $userName = $_POST['userName'];$ C4 g' G. u0 k, ^$ `
- $user_password = $_POST['userPassword'];
e" w& M6 l. }4 y+ q& h" f - $loginSql = $db -> prepare('SELECT * FROM mt_account WHERE user_name=:user_name');
9 d) g" V1 Q+ g" G4 W' Q - $loginSql -> bindParam(':user_name', $userName);) w: ~# J$ h/ O- r% o0 {$ T
1 G" I- x2 Z) n x/ C- if ($loginSql -> execute()): q, C9 J, M# g0 g0 x
- {: z! A) h0 X& {" C3 q, v" z
- $data = $loginSql -> fetch(PDO :: FETCH_ASSOC);+ ]% F# b7 t* W; B8 c2 e
- if ($data)3 I" @: E- d( ?. f8 O2 o7 y- j
- {5 w, B( h9 n2 O) ^
- $bcrypt = new Bcrypt();7 z, C% [) T" @9 w/ f9 \4 Z4 f+ ^
- $isGood = $bcrypt -> verify($user_password, $data['user_password']);
* O, u$ d2 N v. y - if (!$isGood)
, y9 ~- E% \, z% f; k5 G- J - {: E7 E8 O d5 G( R3 N3 h* b+ g
- $error = 'Your password is incorrect.';
2 P8 G* T* S/ @% c2 }6 N' y - }
8 U6 `% V+ `$ W0 |8 m - else6 C5 u" B4 |/ F; Q& Q3 L) o
- {
# W5 z6 o+ }, d3 v9 p4 y4 h - $_SESSION['iMobi_sessionTime'] = time();" {3 A+ C$ A9 h
- $_SESSION['iMobi_userName'] = $userName;, k- C' K* s( c( k& H
- $_SESSION['iMobi_userId'] = $data['user_id'];; _2 h6 Z* P. G A$ P0 [
- $_SESSION['iMobi_timeout'] = $data['user_timeout'];
$ W" a) i: O# \4 M& _) B }+ a - $_SESSION['iMobi_timezone'] = $data['user_timezone'];
+ K4 k8 _" p& p/ k# P [ - $_SESSION['iMobi_Login'] = true;
9 x I, c0 a3 F1 T5 v8 a% s
& W# ~2 E7 Y; p+ V4 T2 @5 b- if (!empty($_SESSION['lastPage']))6 w* V1 ^% h m2 @, f: G. \
- {1 Z0 w0 |: y" g
- $redirect = $_SESSION['lastPage'];
; }& k/ G# ^ d& n* u; G* f- i [4 p - unset($_SESSION[lastPage]);
) U# h3 r3 R+ B7 v - } - C% \# g9 A% h6 ^, \; _" F" U
- else+ S& i6 t) e2 A! @; T3 {
- {
; F% M g7 [, o3 ~ - $redirect = 'campaigns.php';% |0 \% n9 B2 v1 u
- }
7 _& ^. u0 E9 b8 @! {* ~+ K$ k3 k
( r7 i$ m$ ]4 O! j+ Q; P- header('location: ' . $redirect);
Q( \) o. n) G1 L5 l# V3 ?/ ~3 g - exit();
/ l |# D% }5 x - }
/ R9 o: ] @, u5 `, w5 g! }' T4 J - } 8 {3 S: g _; U; V( ?. F
- else; ]2 ^0 ~1 @6 y& M
- {
8 Z, T4 `* A+ t3 {1 p+ B - $error = 'The username entered is not found.';0 \( }1 U# x2 U: D* T
- }
/ [3 ^6 o8 h! J O `# p# a+ h - }
( _* B+ g, B7 }) A5 s - else2 q2 g' O' i7 h
- {
1 l2 ~& o8 N6 Z" ` G) U& ^( H - $error = $loginSql -> errorCode();8 L* d8 H) `) @& t4 B6 `
- $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);
$ D. ?+ Q! G$ p3 I - }8 N: j% ~* e" h
- }
) W, F: A ~, j8 T5 X - ?>" w4 Z" _( h4 X, v
- <!DOCTYPE html>
: r' I4 {" C$ Y2 [7 a9 k. M - <html>- ~, |/ D9 K0 ?$ Z/ V
. p: b7 `/ C; x: W8 `7 ]/ A- <body>
+ W! j" G% S p7 `9 c4 D# p
9 L# Y& A, {# f- <div id="content">0 G7 [6 `) x7 b0 S# H. H7 y5 b9 k
- <div id="main">
5 q& C0 X- L8 g- S6 Q0 @( o& s - <h1>Login</h1>
4 _6 X/ j9 i/ e" W5 E- }9 ` C$ J* z - <?php# G4 u* S8 U- S: r' ]
- if (!empty($error))
4 v$ h. c% E; Q$ ~8 K$ C( H9 m - {8 ?0 d+ y0 k( N
- echo '<div class="error">' . $error . '</div>';
K ^9 C8 E; ~1 v5 @ - }. K; u o9 J* |; u
- ?>
, \" n" N. S; Y - <div id="login">
2 c3 }5 S2 e! S! Q% v - <form method="post" action="">: O9 R& p2 ?( D A. q; ?) R5 A
- <input type="hidden" name="tokenId" value="605871997">/ ^8 E9 N2 T) L, E" Q5 P$ z! ~
- <input type="hidden" name="846c3d198c2af4004cdc58e6e5f00468d81bdda4" value="921541f1e1363396dda7d30197ea67593e9f6bcc">
! i8 D% ^3 l( }' n - <table class="login">) ^0 ^* g* M7 ?/ \: j/ M
- <tr>" P# Z; H- a& [: H; ~- d- k
- <td class="name">Username:</td># A5 [3 v/ w1 }4 ?
- <td><input id="userName" type="text" name="userName" value=""></td>$ f/ D" n1 C+ z }7 c: B6 A
- </tr>5 B8 u: t* I7 z6 u1 \4 T
- <tr>
/ D% r/ Q- J$ C/ {) y3 f - <td class="name">Password:</td>
8 O2 F: Q* ~: v - <td>5 A2 s* x) G2 O2 D6 N8 r
- <input id="userPassword" type="password" name="userPassword"> - y3 G$ K4 z9 g+ O; J
- </td>0 b7 @- y; p) e) V, D" `& z
- </tr># X S1 d* G- x" x" V
- <tr>
3 c% l/ I W2 ^ - <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>
. d) E8 Y T. H$ Z. r$ V - </tr>
* O" N* M" ]+ m7 [: @0 l - </table>
+ ^" s' X- g/ ]( S) B' J7 H - </form>8 L" y, W% w8 P" r# L# n" l+ u: h
- </div>
# F2 Q9 R1 A" N/ C* H4 R* k - </div>1 W$ W# L9 g% Y
- </div>6 y$ p+ v" E( ]/ f, W) W2 C7 f
5 Y5 ] A8 Q( U: o# \# m0 Y% Y5 l- </body>
0 N5 Q! X( U: d - </html>/ B! n) ?4 C" n/ P: K# w1 o' e2 W
复制代码 |
|