Register Register Member Login Member Login Member Login Forgot Password ??
PHP , ASP , ASP.NET, VB.NET, C#, Java , jQuery , Android , iOS , Windows Phone
 

Registered : 109,027

HOME > PHP > PHP Forum > ขอถามข้อผิดพลาดหน่อยครับ Warning: session_start() [function.session-start]: Cannot send session cookie



 

ขอถามข้อผิดพลาดหน่อยครับ Warning: session_start() [function.session-start]: Cannot send session cookie

 



Topic : 030567



โพสกระทู้ ( 69 )
บทความ ( 0 )



สถานะออฟไลน์
Facebook



ตัว chksession.php


Code (PHP)
<?php
session_start();
$sess_userid=$session[sess_userid];
$sess_username=$session[sess_username];
if ($sess_userid<>session_id() or $sess_username=="") {
	header("location: index.html");		exit();
}
?>



มีปัญหานี้ขึ้นมา

Code
Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at C:\AppServ\www\COM\chksession.php:2) in C:\AppServ\www\COM\chksession.php on line 3

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at C:\AppServ\www\COM\chksession.php:2) in C:\AppServ\www\COM\chksession.php on line 3

Warning: Cannot modify header information - headers already sent by (output started at C:\AppServ\www\COM\chksession.php:2) in C:\AppServ\www\COM\chksession.php on line 7


ช่วยบอกบัญหาให้หน่อยครับว่าเป็นที่ไหนครับ



Tag : - - - -







Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2009-08-20 18:43:16 By : topdkclub02 View : 1519 Reply : 20
 

 

No. 1



โพสกระทู้ ( 69 )
บทความ ( 0 )



สถานะออฟไลน์
Facebook

แล้วอีกตัว chkmember.php

<head><meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<?
$user_login=$_POST[user_login];
$pass_login=$_POST[pass_login];

if ($user_login==" " or $pass_login==" ")
{
echo "<h3>ERROR :กรุณากรอกข้อมูลให้ครบ</h3>"; exit();
}
include "connect.php";
$sql="select * from tb_member where username='$user_login'
and password='$pass_login'";
$result=@mysql_db_query($dbname,$sql);
$num=@mysql_num_rows($result);
mysql_close();

if($num<=0){
echo "<h3>ERROR : username หรือ password ไม่ถูกต้อง </h3>";
}
else
{
session_start();
$_session[sess_userid]=session_id();
$_session[sess_username]=$user_login();
header("location: main.php");
}
?>
</head>
กับ index.html

<html>
<head><title>Untitled Document</title><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head>
<body>
<h1>:: Login ::</h1>
<form method="POST" action="chkmember.php">
<table>
<tr>
<td><b>Username :</b></td>
<td><input name="user_reg" type="text"> * </td>
</tr>
<tr>
<td><b>Password : </b></td>
<td><input name="pass_reg" type="password"> * </td><br></br>
</tr>
</table>
<input type="submit" value="Submit">
<input type="reset" value="Reset">
<p><a href="register.html">สมัครสมาชิก</a> |
<a href=""></a></p>
</form>

</body>
</html>
ว่าผิดตรงไหนแล้ว พิมพ์ username กับ password ไปแล้วมันบอกว่า ERROR : username หรือ password ไม่ถูกต้อง ตรงที่ฐานข้อมูลก็มี username กับ password ผมเลยมาถามอีกครับ






Date : 2009-08-20 18:52:20 By : topdkclub02
 


 

No. 2



โพสกระทู้ ( 1,579 )
บทความ ( 3 )

สมาชิกที่ใส่เสื้อไทยครีเอท

สถานะออฟไลน์


เอา session_start(); ไว้บรรทัดแรกเลยคับ
Date : 2009-08-20 19:05:11 By : somparn
 

 

No. 3



โพสกระทู้ ( 69 )
บทความ ( 0 )



สถานะออฟไลน์
Facebook

แล้วอีกตัว chkmember.php

<head><meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<?
session_start();
$user_login=$_POST[user_login];
$pass_login=$_POST[pass_login];

if ($user_login==" " or $pass_login==" ")
{
echo "<h3>ERROR :กรุณากรอกข้อมูลให้ครบ</h3>"; exit();
}
include "connect.php";
$sql="select * from tb_member where username='$user_login'
and password='$pass_login'";
$result=@mysql_db_query($dbname,$sql);
$num=@mysql_num_rows($result);
mysql_close();

if($num<=0){
echo "<h3>ERROR : username หรือ password ไม่ถูกต้อง </h3>";
}
else
{
$_session[sess_userid]=session_id();
$_session[sess_username]=$user_login();
header("location: main.php");
}
?>
</head>
มีปัญหานี้ขึ้นมา
Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at C:\AppServ\www\COM\chkmember.php:3) in C:\AppServ\www\COM\chkmember.php on line 4
Date : 2009-08-20 20:45:30 By : topdkclub02
 


 

No. 4



โพสกระทู้ ( 1,242 )
บทความ ( 13 )

สมาชิกที่ใส่เสื้อไทยครีเอท

สถานะออฟไลน์
Twitter Facebook

<?php
$session_start();
$user_login=$_POST[user_login];
$pass_login=$_POST[pass_login];
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<?
if ($user_login==" " or $pass_login==" ")
{
echo "<h3>ERROR :กรุณากรอกข้อมูลให้ครบ</h3>"; exit();
}
include "connect.php";
$sql="select * from tb_member where username='$user_login'
and password='$pass_login'";
$result=@mysql_db_query($dbname,$sql);
$num=@mysql_num_rows($result);
mysql_close();

if($num<=0){
echo "<h3>ERROR : username หรือ password ไม่ถูกต้อง </h3>";
}
else
{
$_session[sess_userid]=session_id();
$_session[sess_username]=$user_login();
header("location: main.php");
}
?>
</body>
</html>

Date : 2009-08-20 20:50:28 By : DownsTream
 


 

No. 5



โพสกระทู้ ( 69 )
บทความ ( 0 )



สถานะออฟไลน์
Facebook

ดีเลยครับเอาอันบอกไปใส่ก็เกิดปัญหาขึ้นเลยแบบนี้ครับ
Fatal error: Function name must be a string in C:\AppServ\www\COM\chkmember.php on line 2
Date : 2009-08-20 21:02:54 By : topdkclub02
 


 

No. 6



โพสกระทู้ ( 69 )
บทความ ( 0 )



สถานะออฟไลน์
Facebook

<?php
$session_start();
$user_login=$_POST[user_login];
$pass_login=$_POST[pass_login];
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<?
if ($user_login==" " or $pass_login==" ")
{
echo "<h3>ERROR :กรุณากรอกข้อมูลให้ครบ</h3>"; exit();
}
include "connect.php";
$sql="select * from tb_member where username='$user_login'
and password='$pass_login'";
$result=@mysql_db_query($dbname,$sql);
$num=@mysql_num_rows($result);
mysql_close();

if($num<=0){
echo "<h3>ERROR : username หรือ password ไม่ถูกต้อง </h3>";
}
else
{
$_session[sess_userid]=session_id();
$_session[sess_username]=$user_login();
header("location: main.php");
}
?>
</body>
</html>
เอาไปใส่แล้ว ก็เป็นยังนี้
Fatal error: Function name must be a string in C:\AppServ\www\COM\chkmember.php on line 2
แก้ไงครับ
Date : 2009-08-20 21:51:11 By : topdkclub02
 


 

No. 7



โพสกระทู้ ( 69 )
บทความ ( 0 )



สถานะออฟไลน์
Facebook

มีใครรู้ตอบหน่อยครับ
Date : 2009-08-20 22:15:52 By : topdkclub02
 


 

No. 8



โพสกระทู้ ( 830 )
บทความ ( 0 )



สถานะออฟไลน์


จาก

$session_start();

แก้เป็น

session_start();

ครับ
Date : 2009-08-20 22:36:18 By : danya
 


 

No. 9



โพสกระทู้ ( 69 )
บทความ ( 0 )



สถานะออฟไลน์
Facebook

พี่ครับมันหายไปแล้ว บอกว่า ERROR : username หรือ password ไม่ถูกต้อง
ที่จิงก็มีข้อมูล username กับ password แล้วครับ ทำยังไงครับ*0*
Date : 2009-08-20 22:40:42 By : topdkclub02
 


 

No. 10



โพสกระทู้ ( 830 )
บทความ ( 0 )



สถานะออฟไลน์


ตอนเก็บรหัสผ่าน เก็บเป็น md5 หรือเปล่าครับ ???
Date : 2009-08-20 23:11:11 By : danya
 


 

No. 11



โพสกระทู้ ( 69 )
บทความ ( 0 )



สถานะออฟไลน์
Facebook

เก็บตามโค๊ดที่มากันอยู่แล้ว ดูก็ไม่มี md5 เลยครับ แก้ยังไงดี T_T
Date : 2009-08-20 23:16:01 By : topdkclub02
 


 

No. 12



โพสกระทู้ ( 69 )
บทความ ( 0 )



สถานะออฟไลน์
Facebook

register.html
<html>
<head><title>Untitled Document</title><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head>
<body>
<h1>:: Register ::</h1>
<form method="post" action="register2.php">
<table cellpadding="2">
<tr>
<td><b>Username : </b></td>
<td><input name="user_reg" type="text"> * </td>
</tr>
<tr>
<td><b>password :</b></td>
<td><input name="pass_reg" type="password">*</td>
</tr>
<tr>
<td><b>ชื่อ-สกุล :</b></td>
<td><input name="name_reg" type="text">*</td>
</tr>
<tr>
<td><b>เพศ :</b></td>
<td><input name="sex_reg" type="radio" value="ชาย" checked>ชาย
<input name="sex_reg" type="radio" value="หญิง">หญิง</td>
</tr><tr>
<td><b>อีเมล :</b></td>
<td><input name="email_reg" type="text" size="26">*</td>
</tr>
<tr>
<td><b>โทรศัพท์ :</b></td>
<td><input name="tel_reg" type="text" size="26"></td>
</tr>
<tr>
<td><b>ที่อยู่ติดต่อ :</b></td>
<td><textarea name="address_reg" cols="35" rows="3">
</textarea></td>
</tr>
<tr>
<td>&nbsp;</td>
<td><input type="Submit" value="Submit">
<input type="Reset" value="Reset"></td>
</tr>
</table>
</form>
</body>
</html>

register2.php
<head><meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<?
$user_reg=$_POST[user_reg];
$pass_reg=$_POST[pass_reg];
$name_reg=$_POST[name_reg];
$sex_reg=$_POST[sex_reg];
$email_reg=$_POST[email_reg];
$address_reg=$_POST[address_reg];
$date_reg=date("y-m-d");

if ($user_reg=="" or $pass_reg=="" or $name_reg==""){
echo "<h3>error : กรุณากรอกข้อมูลให้ครบนะครับ<h3>"; exit();
}
include "function.php";
if (!checkemail($email_reg)) {
echo "<h3>error : รูปแบบอีเมลที่กรอกไม่ถูกต้องนะครับ</h3>"; exit();
}
include "connect.php";
$sql="select * from tb_member where username='$user_reg' ";
$result=@mysql_db_query($dbname,$sql);
$num=@mysql_num_rows($result);
if($num>0){
echo "<h3>error : Username ซ้ำครับ </h3>"; exit ();
}
$sql="insert into tb_member
values('','$user_reg','$pass_reg','$name_reg','$sex_reg',
'$email_reg','$tel_reg','$address_reg','$date_reg')";
$result=@mysql_db_query($dbname,$sql);
if ($result) {
echo"<h3>ข้อมูลของท่านถูกบันทึกเรียบร้อยแล้ว</h3>";
echo"<a href='index.html'>คลิกเพื่อเข้าระบบสมาชิก</a>
<br></br>";
}else{
echo "<h3>ไม่สามารถสมัครสมาชิกได้</h3>";
}
mysql_close();
?>
</head>
Date : 2009-08-20 23:29:30 By : topdkclub02
 


 

No. 13



โพสกระทู้ ( 69 )
บทความ ( 0 )



สถานะออฟไลน์
Facebook

chkmember.php
<?php
session_start();
$user_login=$_POST[user_login];
$pass_login=$_POST[pass_login];
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<?
if ($user_login==" " or $pass_login==" ")
{
echo "<h3>ERROR :กรุณากรอกข้อมูลให้ครบ</h3>"; exit();
}
include "connect.php";
$sql="select * from tb_member where username='$user_login'
and password='$pass_login'";
$result=@mysql_db_query($dbname,$sql);
$num=@mysql_num_rows($result);
mysql_close();

if($num<=0){
echo "<h3>ERROR : username หรือ password ไม่ถูกต้อง </h3>";
}
else
{
$_session[sess_userid]=session_id();
$_session[sess_username]=$user_login();
header("location: main.php");
}
?>
</body>
</html>

chksession.php

<? session_start();
$sess_userid=$session[sess_userid];
$sess_username=$session[sess_username];
if ($sess_userid<>session_id() or $sess_username=="") {
header("location: index.html"); exit();
}
?>

function.php

<head><meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<?
function displaydate($x){
$thai_m=array("Ҥ","Ҿѹ","չҤ","¹","Ҥ",
"Զع¹","áҤ","ԧҤ","ѹ¹","Ҥ","Ȩԡ¹","ѹҤ");
$date_array=explode("-",$x);
$y=$date_array[0];
$m=$date_array[1]-1;
$d=$date_array[2];

$m=$thai_m[$m];
$y=$y+543;

$displaydate="$d $m $y";
return $displaydate;
}
function checkemail($checkemail) {
if (ereg( "^[^@]+@([a-zA-Z0-9\-]+\.)+([a-zA-Z0-9\-]{2}
|net|com|gov|mil|org|edu|int)$",$checkemail ) ) {
return true;
} else {
return false;
}
}
?>
</head>

index.html

<html>
<head><title>Untitled Document</title><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head>
<body>
<h1>:: Login ::</h1>
<form method="POST" action="chkmember.php">
<table>
<tr>
<td><b>Username :</b></td>
<td><input name="user_reg" type="text"> * </td>
</tr>
<tr>
<td><b>Password : </b></td>
<td><input name="pass_reg" type="password"> * </td><br></br>
</tr>
</table>
<input type="submit" value="Submit">
<input type="reset" value="Reset">
<p><a href="register.html">สมัครสมาชิก</a> |
<a href=""></a></p>
</form>
</body>
</html>

connect.php

<head><meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<?
$host="localhost";
$user="root";
$pw="root";
$dbname="db_member";
$c = mysql_connect($host,$user,$pw);
if (!$c) {
echo "<h3>ERROR : ไม่สามารถติดต่อกับฐานข้อมูลได้</h3>";
exit();
}
mysql_query("SET NAMES UTF8");
?>
</head>


ช่วยดูให้หน่อยครับว่าผิดตรงไหม ทำไหมใส่รหัสเข้าไปที่ Login ERROR : username หรือ password ไม่ถูกต้อง
ที่จิงก็มีข้อมูล username กับ password แล้วครับ ทำยังไงครับ
Date : 2009-08-21 06:58:34 By : topdkclub02
 


 

No. 14



โพสกระทู้ ( 69 )
บทความ ( 0 )



สถานะออฟไลน์
Facebook

ช่วยหน่อยครับ+++++++
Date : 2009-08-21 12:32:24 By : topdkclub02
 


 

No. 15



โพสกระทู้ ( 69 )
บทความ ( 0 )



สถานะออฟไลน์
Facebook

ไม่มีใครตอบได้หรือครับ+++
Date : 2009-08-24 07:20:18 By : topdkclub02
 


 

No. 16



โพสกระทู้ ( 11,835 )
บทความ ( 10 )

สมาชิกที่ใส่เสื้อไทยครีเอท Hall of Fame 2012

สถานะออฟไลน์


$sql="select * from tb_member where username='$user_login'
and password='$pass_login'";
echo $sql; // ตรงนี้ออกมาว่าอะไรก็เอาไป query ใน phpMyAdmin ดูนะ
Date : 2009-08-24 09:16:17 By : plakrim
 


 

No. 17



โพสกระทู้ ( 69 )
บทความ ( 0 )



สถานะออฟไลน์
Facebook

$sql="select * from tb_member where username='$user_login'
and password='$pass_login'";
echo $sql; // ตรงนี้ออกมาว่าอะไรก็เอาไป query ใน phpMyAdmin ดูนะ

??ครับให้ไปแก้ตรงไหนครับบอกให้มากกว่านี้ได้ไหมครับ
Date : 2009-08-24 12:55:11 By : topdkclub02
 


 

No. 18



โพสกระทู้ ( 69 )
บทความ ( 0 )



สถานะออฟไลน์
Facebook

select * from tb_member where username='' and password=''
ERROR : Username หรือ Password ไม่ถูกต้อง
ขึ้นมาแบบนี้ครับ
Date : 2009-08-24 13:01:07 By : topdkclub02
 


 

No. 19

Guest


รับค่าตัวแปร ในหน้าchkmember.php เป็นตัวแปร user_login และ pass_login
chkmember.php
<?php
session_start();
$user_login=$_POST[user_login];
$pass_login=$_POST[pass_login];
?>
----------------------------------------------------------

ส่วนหน้าที่รับฟอร์ม ในหน้า index.html ชื่อตัวแปร คือ user_reg และ pass_reg

<input name="user_reg" type="text">
<input name="pass_reg" type="password">

--------------------------------------------------------

ตัวแปรส่งค่า ตั้งชื่อไม่ตรงกันอ่ะ เปลี่ยนนะ
Date : 2010-01-18 04:57:13 By : ขุนพล คำเกษ
 


 

No. 20



โพสกระทู้ ( 10 )
บทความ ( 0 )



สถานะออฟไลน์


ปัญหาเหมือนกันเลย
Date : 2010-08-21 11:27:09 By : illusionsb
 

   

ค้นหาข้อมูล


   
 

แสดงความคิดเห็น
Re : ขอถามข้อผิดพลาดหน่อยครับ Warning: session_start() [function.session-start]: Cannot send session cookie
 
 
รายละเอียด
 
ตัวหนา ตัวเอียง ตัวขีดเส้นใต้ ตัวมีขีดกลาง| ตัวเรืองแสง ตัวมีเงา ตัวอักษรวิ่ง| จัดย่อหน้าอิสระ จัดย่อหน้าชิดซ้าย จัดย่อหน้ากึ่งกลาง จัดย่อหน้าชิดขวา| เส้นขวาง| ขนาดตัวอักษร แบบตัวอักษร
ใส่แฟลช ใส่รูป ใส่ไฮเปอร์ลิ้งค์ ใส่อีเมล์ ใส่ลิ้งค์ FTP| ใส่แถวของตาราง ใส่คอลัมน์ตาราง| ตัวยก ตัวห้อย ตัวพิมพ์ดีด| ใส่โค้ด ใส่การอ้างถึงคำพูด| ใส่ลีสต์
smiley for :lol: smiley for :ken: smiley for :D smiley for :) smiley for ;) smiley for :eek: smiley for :geek: smiley for :roll: smiley for :erm: smiley for :cool: smiley for :blank: smiley for :idea: smiley for :ehh: smiley for :aargh: smiley for :evil:
Insert PHP Code
Insert ASP Code
Insert VB.NET Code Insert C#.NET Code Insert JavaScript Code Insert C#.NET Code
Insert Java Code
Insert Android Code
Insert Objective-C Code
Insert XML Code
Insert SQL Code
Insert Code
เพื่อความเรียบร้อยของข้อความ ควรจัดรูปแบบให้พอดีกับขนาดของหน้าจอ เพื่อง่ายต่อการอ่านและสบายตา และตรวจสอบภาษาไทยให้ถูกต้อง

อัพโหลดแทรกรูปภาพ

Notice

เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ
อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง

   
  เพื่อความปลอดภัยและการตรวจสอบ กระทู้ที่แทรกไฟล์อัพโหลดไฟล์จากที่อื่น อาจจะถูกลบทิ้ง
 
โดย
อีเมล์
บวกค่าให้ถูก
<= ตัวเลขฮินดูอารบิก เช่น 123 (หรือล็อกอินเข้าระบบสมาชิกเพื่อไม่ต้องกรอก)







Exchange: นำเข้าสินค้าจากจีน, Taobao, เฟอร์นิเจอร์, ของพรีเมี่ยม, ร่ม, ปากกา, power bank, แฟลชไดร์ฟ, กระบอกน้ำ

Load balance : Server 05
ThaiCreate.Com Logo
© www.ThaiCreate.Com. 2003-2024 All Rights Reserved.
ไทยครีเอทบริการ จัดทำดูแลแก้ไข Web Application ทุกรูปแบบ (PHP, .Net Application, VB.Net, C#)
[Conditions Privacy Statement] ติดต่อโฆษณา 081-987-6107 อัตราราคา คลิกที่นี่