Not for 'how-to' coding questions but PHP theory instead, this forum is here for those of us who wish to learn about design aspects of programming with PHP.
I'm looking for a viable way of coding some PHP that inserts the users MAC address into my MySQL table when a request is sent (form submission). I know that PHP is server-side scripting and all, but it must be possible; surely?
Why I need to do this is because, so far I've been logging the IP when a request is sent so that I can track the usage of individuals (I don't need their identity) just to track if it's the same device making requests. But the project is targeted at mobile devices, so the IP addresses are changing quite frequently so I'm finding that I can't accurately track usage. If anybody can suggest a better way of overcoming this, without using the device's MAC address then please feel free to leave comments!
Could this perhaps be processed by some sort of Javascript and then passed as a variable? I wanted to steer away from using Cookies really as they can be cleared, then I'll again get duplicated values. Actually thinking on .. I might look into having some Javascript get the MAC address, store it as a cookie, and then have the PHP read the cookie. That way it'll never change.
I totally understand this, but the end product is only being used by mobile devices (iPhones in particular); so unless the device is JailBroken, they're not going to be able to change the devices MAC address.
mikeashfield wrote:Could this perhaps be processed by some sort of Javascript and then passed as a variable?
Probably easier to spoof than the IP using a browser plug-in...assuming your goal is added security. If you're just trying to get a MAC then you could try javascript. I'm not 100% sure the MAC is available at that layer, but I've never looked into it. General Javascript is not that trusted. I'm guessing you'd have to use signed javascript (disabled by default in FF) or some activeX thing in IE.
The MAC address isn't accessible by Javascript. On the iPhone you're going to have pretty much zero opportunity to access the MAC address via a website. You should stop trying to build a system that requires the user not do something, and instead build it so it's flexible enough to recover when they inevitably do.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.