javascript, php, cookies
- by kennedy
When i declare mac = 123, my internet explorer and firefox will keep refresh non-stop. And if i declare mac = getMacAddress it returns a value 1...
I'm able to do a document.write(getMacAddress()) and it would able to display the mac address nicely.
1) Why my explorer will keep refreshing non-stop when i code it manually with "123"
2) why is the document.write able to display out, and when i store it to the cookie, somehow it didnt mange to capture into the cookie and it return a value of "1".
Anyone help?
create_users.php
<script language="JavaScript">
function getMacAddress(){
document.macaddressapplet.setSep( "-" );
return (document.macaddressapplet.getMacAddress());
}
function setCookie(c_name,value) {
document.cookie = c_name + "=" +escape(value);
}
//error checking
//var mac = getMacAddress();
var mac = "123";
setCookie('cookie_name',mac);
window.location = "checkAvailability.php";
</script>
checkAvailability.php
$javascript_cookie_value = isset($_COOKIE["cookie_name"]) ? $_COOKIE["cookie_name"] : 1;
mysql_query("INSERT INTO test (mac) VALUES ('$javascript_cookie_value')");