|
|
|
Warning: Cannot modify header information - headers already sent by (output started at... |
|
|
|
|
|
|
|
มันเกิดปัญหาในบรรทัดที่สั่ง cookie ทำงานครับ... เป็นเพราะอะไรหรอครับ
Code (PHP)
<?php
error_reporting(E_ALL^E_NOTICE);
session_start();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><?php echo $title; ?></title>
</head>
<body>
<?php require('pages/index_login.php'); ?>
</body>
</html>
'pages/index_login.php
<?php
error_reporting(E_ALL^E_NOTICE);
session_start();
if(basename(__FILE__) == basename($_SERVER['PHP_SELF'])){
require('direct_index.php');
exit();
}
$chkLog = 0;
//-----> time
$cook_nm = 'log_user_UN';
$cook_pw = 'logPWhack';
$cook_time = 60*60*24*30; //
require_once("includes/connection.php");
date_default_timezone_set('Asia/Bangkok');
$now = date("Y-m-d H:i:s");
//-----> End time
$r_num = $_POST['numm'];
$username = $_REQUEST['userLogin'];
$password = $_REQUEST['passLogin'];
$numSubmitLog += $r_num;
if((!empty($username)) and (!empty($password)) ){
// user pass not null
require_once("includes/functions.php");
$username = trim($_POST['userLogin']);
$password = encodePassword(trim($_POST['passLogin']));
require("includes/fnc_manage_db.inc.php");
$condition = 'user_name="'.$username .'" AND password="'.$password.'"';
$chkUserDB = selectOneData("*","users",$condition);
if($chkUserDB){
$chkLog = 1;
$_SESSION['ses_user']=$username;
if($_REQUEST['saveuser']=="on"){
setcookie($cook_nm,$username,time()+$cook_time);
}else{
setcookie($cook_nm,"",time());
}
setcookie('numLog',"",time());
}else{
setcookie('numLog',$numSubmitLog,time()+60);
$_SESSION['numLogg'] = $numSubmitLog;
$chkLog = 0;
echo $_SESSION['numLogg'];
}
}else{
$chkLog = 0;
}
if($chkLog == 0){
?>
<div class="contrianLogin">
<table class="tatbleAvatar" border="0" cellspacing="0" cellpadding="0">
<tr align="center" valign="middle">
<td align="center" valign="middle">
<a href="#"><img src="images/my_pic2.jpg" border="0" class="gradualshine1" onmouseover="slowHighs(this)" onmouseout="slowLows(this)" /></a></td>
</tr>
</table>
<form id="frmLogin" name="frmLogin" method="post" action="<?php $_SERVER['DOCUMENT_ROOT']; ?>" enctype="multipart/form-data" onsubmit="return checkLogin()">
<input type="hidden" name="numm" value="1" />
<div class="brLogin">
<input type="text" name="userLogin" id="userLogin" class="textbox" size="16"/>
<?
$num = 6;
if($_REQUEST['numLog'] > 1){
$nm = $num - $_COOKIE['numLog'] ;
echo "::".$nm;
}
?>
</div>
<div class="brLogin">
<input type="password" name="passLogin" id="passLogin" class="textbox" size="16" /></div>
<div class="brLogin"><label for="remember" class="cur" style="alignment-adjust:top; color:#999;">
<input type="checkbox" name="saveuser" id="saveuser" <?=$svusr?> />Remember</label>
</div><div class="brLogin">
<input type="submit" name="submLogin" id="submLogin" value="Login" /></div>
<div class="brLogin">
<span>Forget Password</span>
</div>
</form>
</div>
<?php
}
if($chkLog == 1)
echo "Success...";
?>
Tag : PHP, MySQL, HTML/CSS
|
|
|
|
|
|
Date :
2010-11-05 19:02:02 |
By :
t-monroe |
View :
2656 |
Reply :
5 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ข้อจำกัดของ setcookies(); คือ ห้ามใช้หลังคำสั่งหรือฟังก์ชันต่างๆ ของ php ครับ
แก้ตามนี้เด้อ.อ.....
ให้ใช้คำสั่ง ob_start(); ไว้บนสุดของ tag php แล้วก็ ob_end_flush(); ไว้บรรทัดล่างสุดเพื่อจบการทำงานของ ob_start(); งั๊บ
|
|
|
|
|
Date :
2010-11-05 19:22:07 |
By :
ppanchai |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ได้แล้วครับ... ลองใช้ทั้ง 2 ด้วยกัน...ไม่เข้าใจมันจิงๆ
ob_start();
session_start();
|
|
|
|
|
Date :
2010-11-05 19:24:42 |
By :
t-monroe |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ถามต่อหน่อยครับ...
$numSubmitLog += $r_num;
$numSubmitLog ทำไมมันไม่เพิ่มค่าครับ...
|
|
|
|
|
Date :
2010-11-05 20:33:45 |
By :
t-monroe |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ช่วยดูให้หน่อยครับ...
|
|
|
|
|
Date :
2010-11-05 21:57:05 |
By :
t-monroe |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 02
|