0

the application returns a value "1" in the database instead of the mac address...

I'm able to document.write the output of the mac address, but not able to have it store in the database.

Is the program using the previous cookie? (but Ive deleted all the cookies from the pc)

but if i change the variable mac to string data, it keep refresh my webpage. Why is that so... (var mac="test data";)

Please 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);
}

//var mac="test data";
var mac = getMacAddress();


setCookie('cookie_name',mac);
window.location = "checkAvailability.php";

</script> 

<script type="text/javascript">
document.write(getMacAddress());
</script>

checkAvailiability.php

$dbhost = 'localhost';
$dbuser = 'root';
$dbname = 'registration';
mysql_connect($dbhost, $dbuser) or die("Could not connect database");
mysql_select_db($dbname);
$javascript_cookie_value = isset($_COOKIE["cookie_name"]) ? $_COOKIE["cookie_name"] : 1;
mysql_query("INSERT INTO test (mac) VALUES ('$javascript_cookie_value')");
2
  • 2
    use firebug and look at the Cookie tab to see what was written to cookies.
    – silent
    Jan 26, 2010 at 8:51
  • but if i used FF, there is no issue with the saving but the browser keep refreshing non-stop...
    – kennedy
    Jan 26, 2010 at 8:59

2 Answers 2

1

Why not:

window.location = "checkAvailability.php?mac=" + mac;

and eliminate cookie problems?

I presume you've checked that the applet is behaving as you expect?

C.

0

Assuming that code appears in checkAvailability.php, then it keeps refreshing because you have window.location = "checkAvailability.php"; with no logic to stop it running — so every time it loads the page, it gets redirected to that URI.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.