Metasearching Posted April 19, 2012 Share Posted April 19, 2012 Hi, I'm an researcher (and complete coding noob), and am planning a longitudinal study that requires e-mail follow-up with subjects taking an initial survey. For purposes of ethics/anonymity due to sensitive survey data, I'd like the acquired e-mails to be saved uncoupled from the survey responses; this is simple to deal with, and I use a basic PHP e-mail form, which injects the email address in a table in MySQL in a different server than the one used for the survey. The issue is that the e-mails are saved in the MySQL database in order of injection, thus it is still theoretically possible for me to link the e-mails back to the survey responses (which have a time stamp that I cannot remove). Ideally I would like not to be able (at all) to link the e-mails to the survey responses, and one way to do that (since I don't save the e-mail injection timestamps in MySQL) might be to have the e-mails saved in MySQL in a random order. Not sure if this is possible, and not even sure if this would be via PHP or MySQL side of things. The server is on godaddy and uses Starfield interface for MySQL but I cannot find an option for random insert/saving of table items (emails). They are saved in order of injection. Any solution for this? Thanks, Quote Link to comment Share on other sites More sharing options...
Metasearching Posted April 19, 2012 Author Share Posted April 19, 2012 I everyone, I think I posted in wrong area (should be in coding section). I will repost there, and await your responses Quote Link to comment Share on other sites More sharing options...
jstrike Posted April 27, 2012 Share Posted April 27, 2012 Not sure if you got your answer elsewhere yet (I'm new too and didn't realize this was the wrong place for my post, lol): Probably the easiest way to do this would be to not have a primary or unique key in your MySQL table. If you do need some kind of unique handle to sort them by or make it easier to delete them, generate a long random string (20 bytes ought to do the trick) and use that as the index field. MYSQL CREATE TABLE randomized_responses (randomID VARCHAR(20), response TEXT, PRIMARY KEY(randomID)); PHP $letters = array("A","a","B","b"...); $randomstring = ""; for ($i=0;$i<20;$i++) { $randomstring .= $letters[rand(0,51)]; } $q = mysql_query("INSERT INTO randomized_responses (randomID, response) VALUES('$randomstring','$response');", $sqlConn); //remember to use mysql_real_escape_string to clean the $response of malicious SQL injection before putting it into the database... if (mysql_affected_rows($sqlConn)<1) { //That random key was already used. Get another key and try again. Obviously putting this whole thing in a function and returning affected rows makes sense if you're worried about collisions. } Hope this helps... Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.