You are confused because you try to get the attribute of the element, that is in client side, from the server side and the server doesn't know this information.
On the client side you works with JavaScript and what you can do is store this value in a cookie, for example. Then get this value from the server side with PHP.
The following code is provided by: http://abarcarodriguez.com/365/show?e=10
// mini-jQuery
var $ = function (id) { return document.getElementById(id); };
// Caché
$set = $('set');
$read = $('read');
$delete = $('delete');
$logs = $('logs');
// Logs en textarea
var log = function (log) { $logs.value = log + '\n' + $logs.value; }
// Crear Cookie
var crearCookie = function (key, value) {
expires = new Date();
expires.setTime(expires.getTime() + 31536000000);
cookie = key + "=" + value + ";expires=" + expires.toUTCString();
log("crearCookie: " + cookie);
return document.cookie = cookie;
}
// Leer Cookie
var leerCookie = function (key) {
keyValue = document.cookie.match("(^|;) ?" + key + "=([^;]*)(;|$)");
if (keyValue) {
log("getCookie: " + key + "=" + keyValue[2]);
return keyValue[2];
} else {
log("getCookie: " + key + "=" + "null");
return null;
}
}
// Eliminar Cookie
var eliminarCookie = function (key) {
log("eliminarCookie: " + key);
return document.cookie = key + '=;expires=Thu, 01 Jan 1970 00:00:01 GMT;';
}
// Botones para Demo
$set.onclick = function () {
key = $('key').value;
value = $('value').value;
crearCookie(key, value);
}
$read.onclick = function () {
key = $('key-read').value;
leerCookie(key);
}
$delete.onclick = function () {
key = $('key-delete').value;
eliminarCookie(key);
}
and the code of PHP to get the value of the cookie is:
$_COOKIE["nombre"])
read this in: http://php.net/manual/en/reserved.variables.cookies.php