|
发表于 2015-12-6 12:52:22
|
显示全部楼层
不用这么麻烦 用这个login.php就好了
5 h! {! [1 w6 i, U/ V- . w( |9 y$ h# t$ R
- <?php
5 l' P$ o- l# [& ~) }+ p - $error = '';! O) p d: E7 N- l& z
- $_SESSION['imobi_data'] = array('imVersion' => '3.7', 'xmlVersion' => '3.5');) w/ }3 o5 b Z* \
$ _8 |- ^( L& Y3 o: E3 u- if ($_SERVER['REQUEST_METHOD'] == 'POST')
8 U* E$ V) e1 l0 U - {: R) d5 P/ `- d# u: Q P
- include( 'mt/mt_pconnect.php' );
) n. r! t7 Z7 g1 u1 C - include( 'mt/mt_pwd.php' );
4 I2 M) C2 N, t; J4 t/ y - $userName = $_POST['userName'];& m& I% Y, a- J# Q
- $user_password = $_POST['userPassword'];/ {( v( Q. b; a$ ~6 N1 }
- $loginSql = $db -> prepare('SELECT * FROM mt_account WHERE user_name=:user_name');
$ K a8 h6 Q) a& w5 [& J, ^+ P3 ^ - $loginSql -> bindParam(':user_name', $userName);' _; Q$ { M1 S" o2 _$ y
- 2 s5 X [" K8 s& ^" P' V- c/ A8 w. q+ f
- if ($loginSql -> execute())
4 M _( @3 v4 E - {
: N5 @* @0 \9 D$ p! \ - $data = $loginSql -> fetch(PDO :: FETCH_ASSOC);6 f8 B; d' V; g& d
- if ($data)1 R% U* }2 u. i6 p$ }* m
- {) m; x3 I! `' K9 S) j. B
- $bcrypt = new Bcrypt();& p/ N+ K$ A$ B2 k S5 Z
- $isGood = $bcrypt -> verify($user_password, $data['user_password']);
/ J( f) I: Z) x, D7 D9 u - if (!$isGood)* K2 x6 n# Y# Y" _4 d
- {6 B* y% S5 P5 i2 P; R. n7 N( J5 O# B
- $error = 'Your password is incorrect.';
9 ]+ g- `3 X9 |/ {3 M% a - }
8 n% G, E/ h0 k% ~) P' {6 I. t; B - else' a$ D% ]6 W) X. l) D2 h) c; H
- {& s% p l# K3 z" ] [4 x& \, J" ^
- $_SESSION['iMobi_sessionTime'] = time(); Z! b2 l( U0 C H
- $_SESSION['iMobi_userName'] = $userName;8 Z; v& l4 m2 x7 {+ {8 y3 j
- $_SESSION['iMobi_userId'] = $data['user_id'];& T7 @+ h! Q# p9 Z8 d
- $_SESSION['iMobi_timeout'] = $data['user_timeout'];
& q* ~4 \' O9 s3 k1 a7 m) A! ? - $_SESSION['iMobi_timezone'] = $data['user_timezone'];+ q# S( ?. |' N1 ]/ u; }. [
- $_SESSION['iMobi_Login'] = true;
3 M: I# l1 f! U% C2 ]2 @ - ) l) c" \7 z6 K% V: [1 ?% C
- if (!empty($_SESSION['lastPage']))
) ~( M. N$ u! y - {
5 n( f. a! t8 X - $redirect = $_SESSION['lastPage'];
* P3 v. I2 p5 T* s - unset($_SESSION[lastPage]);8 u4 e3 H: X$ J+ y3 P
- }
! f& ?1 P6 X+ M1 x/ u" r - else
1 M0 R" n8 v5 z$ t8 _6 i) ~ - { z0 z# ]0 P; h& t6 P0 h
- $redirect = 'campaigns.php';
, B F8 k) o( Q/ P1 a9 ~0 r+ [. x - } 3 m4 [6 k7 r$ q' G3 V
& W, @; a, E8 _3 n9 {; Z- header('location: ' . $redirect);" |( m( B1 d4 K
- exit();
8 p l) e. a \/ U: n - } / D% |. ~3 F, Y- ^7 R% B; b+ i6 F. x
- }
6 _3 M( j- }8 U& O# K1 I# \3 K0 l - else
/ T+ C& @+ P3 d, N* E8 q, X - {* t. }2 ^, Q; @* I9 S
- $error = 'The username entered is not found.';! E0 l9 h: I! u, N0 J- h& u: ]
- }! T v! Q n; i# O
- }
* @$ s9 |9 r/ n - else
z9 e2 i8 b/ P! i3 o9 m2 n' h3 Q - {
; b8 v+ m1 n D B. ] - $error = $loginSql -> errorCode();
1 P" ~; m0 s3 p! O) B - $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);" {) L ]5 p( b# N$ \; G
- }5 ]$ |, I; y+ g! b
- }9 @: M' j# Q" c
- ?>& w* d- v# S( z! s+ Q- d) S
- <!DOCTYPE html>
* t$ S8 Z( l) t+ b - <html>
2 w7 G+ t2 } W* m - - s! [" a3 M! U* I$ `# l5 e. o
- <body>
( {, E2 Z/ k* T1 H- T& }4 K i
, d* e) w, U" k+ K- <div id="content">( L+ N* \) j" S3 d2 a" k, N
- <div id="main">" x" ]6 v4 m* |2 z
- <h1>Login</h1>7 D, X8 [; n' O! {) D3 K3 K9 c4 T
- <?php K9 s5 C3 ^5 b
- if (!empty($error))
x8 L1 Z% E/ }* r5 _ - {
) G5 U1 G: Q! E m- ]" y - echo '<div class="error">' . $error . '</div>';
! j% ~, o: Y; A; l5 ` - }
H6 C. @( W) f2 H - ?> R5 o$ T t: H) ]9 [
- <div id="login">
, i8 q, p& Q! { - <form method="post" action="">
; G8 O4 }! W& e1 u( N, F! h: q - <input type="hidden" name="tokenId" value="605871997">, m2 Y6 a6 i) l
- <input type="hidden" name="846c3d198c2af4004cdc58e6e5f00468d81bdda4" value="921541f1e1363396dda7d30197ea67593e9f6bcc">. B+ x5 d/ ^$ I8 u( s# O& S( V
- <table class="login">
5 W6 V1 N, `# R# o' F' K7 h - <tr>) J0 H$ l0 _( T# f: T9 i3 l
- <td class="name">Username:</td>/ J9 q" \, f# H
- <td><input id="userName" type="text" name="userName" value=""></td>8 x$ {- y a1 z6 [
- </tr>
) b& ~. w2 H; V. m( p - <tr>; b# x! _) T# V; D) I
- <td class="name">Password:</td>
7 w, C3 X5 C; q6 n' | - <td>7 R/ E" ]& P6 G4 ?
- <input id="userPassword" type="password" name="userPassword"> + J; f" m' D4 |% L) ^$ y: X0 U! E
- </td>5 p: `0 ]3 w( r% ^8 ~
- </tr>' t4 B4 G! c0 N E4 H6 A
- <tr>
1 `, V! @4 w0 ~7 ]5 v* p - <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>
! ^4 l& R" I! A - </tr>3 C/ p) J5 A6 R1 O
- </table> W8 j, C& F$ z3 ^
- </form>8 r' Y4 c5 f) n0 W1 [% w) ]
- </div>
6 y. T) ^1 P6 U$ @$ ?+ I. o - </div>
/ ~/ G! Z8 D1 r! i& X4 |% a - </div>
, h0 a6 j: z% y9 g# \5 L
( x; O$ H- [+ n) \! U7 g+ F$ ]5 y- </body>, T5 M N& C7 n" @/ E' h
- </html>
: g$ @& [; y6 j8 k% [: i
复制代码 |
|