i get coockie value by javascript :
-----------start code ---------
<html>
<script language="JavaScript">
function readCookie(name)
{
var cookieValue = "";
var search = name + "=";
if(document.cookie.length > 0)
{
offset = document.cookie.indexOf(search);
if (offset != -1)
{
offset += search.length;
end = document.cookie.indexOf(";", offset);
if (end == -1) end = document.cookie.length;
cookieValue = unescape(document.cookie.substring(offset, end))
}
}
return cookieValue;
}
</script>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<script language="JavaScript">
$loginval =(readCookie("isforumlogin"));
$loginid =(readCookie("useridforum"));
</script>
</body>
</html>
------end code----
But i wish put this (php) code in body :
<?php
mysql_connect("host", "username", "password") or die("Could not connect");
mysql_select_db("database") or die(mysql_error());
$UserD = $loginid
$sql = mysql_query("SELECT UserName FROM users WHERE id = $UserD ");
fetch_em = mysql_fetch_array($sql);
echo fetch_em["username"];
?>
how can i set $UserD = $loginid ????
thanks