javascript function save to cookies
<p>For now, i have a function macs, and i need to implement this function to save inside a cookie and have it stored in mysql..</p>

<p>So how am i supposed to have this function together?</p>

<pre><code>        &lt;script language="JavaScript"&gt;

        function getMacAddress(){
          document.macaddressapplet.setSep( "-" );
          return (document.macaddressapplet.getMacAddress());
        }

        function setCookie(c_name,value,expiredays)
        {
        var exdate=new Date();
        exdate.setDate(exdate.getDate()+expiredays);
        document.cookie=c_name+ "=" +escape(value)+ ((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
        }

        setCookie('cookie_name','getMacAddress()','1');
        &lt;/script&gt; 
        &lt;body&gt;

        &lt;?php
         //Defaults to 1
        $javascript_cookie = isset($_COOKIE["cookie_name"]) ? $_COOKIE["cookie_name"] : 1;
        echo "$javascript_cookie";

        // db insert query
        $dbhost = 'localhost';
        $dbuser = 'root';
        $dbname = 'registration';
        mysql_connect($dbhost, $dbuser) or die("Could not connect database");
        mysql_select_db($dbname);
        $sql_query = mysql_query("SELECT * from user WHERE UserID ='".$_POST['newUserID']."'");
        $sql = "INSERT INTO test(mac) VALUES ('".$javascript_cookie."')";
        mysql_query($sql);
        ?&gt;
</code></pre>
