Được gửi bởi
TYchuot
mình bị lỗi khi sử dụng biến session bạn nào biết chỉ cho mình với:
lỗi đó là:Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at c:\inetpub\wwwroot\thuchanh\th1.php:9) in c:\inetpub\wwwroot\thuchanh\th1.php on line 11
Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at c:\inetpub\wwwroot\thuchanh\th1.php:9) in c:\inetpub\wwwroot\thuchanh\th1.php on line 11
Warning: Unknown(): Your script possibly relies on a session side-effect which existed until PHP 4.2.3. Please be advised that the session extension does not consider global variables as a source of data, unless register_globals is enabled. You can disable this functionality and this warning by setting session.bug_compat_42 or session.bug_compat_warn to off, respectively. in Unknown on line 0
mong các cao thủ giúp đỡ cảm ơn nhiều.
[=========> Bổ sung bài viết <=========]
cả lỗi này nữa:Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at c:\inetpub\wwwroot\thuchanh\next.php:8) in c:\inetpub\wwwroot\thuchanh\next.php on line 9
Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at c:\inetpub\wwwroot\thuchanh\next.php:8) in c:\inetpub\wwwroot\thuchanh\next.php on line 9
Notice: Undefined index: username in c:\inetpub\wwwroot\thuchanh\next.php on line 10
Notice: Undefined index: email in c:\inetpub\wwwroot\thuchanh\next.php on line 11
hoang van Quynh
[=========> Bổ sung bài viết <=========]
chương trình đơn giản mình viết như sau:trang th1.php
<!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=iso-8859-1" />
<title> session </title>
</head>
<body>
<?php
//khoi tao bien session
session_start();
// khai bao bien
$username = "admin";
$email = "myloveql@yahoo.com.vn";
$fullname = "Hoang Van Quynh";
//dang ki bien session
session_register("username");
session_register("email","fullname");
?>
3 session register
<a href="next.php"> next page </a>
</body>
</html>
và trang next.php như sau:
<!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=iso-8859-1" />
<title>Untitled Document</title>
</head>
<body>
<?php
session_start();
echo $username;
echo $email;
?>
</body>
</html>
Bookmarks