Please see the release notes and apply update scripts if necessary."); if($valid_entry && !$forgot_passcode) { // data is valid, check to see if the subject exists by these criteria: first/last name, dob $enc_key = subinfo_encryption_key(); $sql_match_passcode = sprintf("select subject_id, aes_decrypt(`name_last`,'%s') as name_last, aes_decrypt(`name_first`,'%s') as name_first, aes_decrypt(`dob`,'%s') as dob from subject where aes_decrypt(`passphrase`,'%s')='%s'", $enc_key,$enc_key,$enc_key,$enc_key,$passcode); $result_match_passcode = mysql_query($sql_match_passcode) or report_error_form(mysql_error()); $matched_subject = FALSE; //MIGHT WANT TO DEAL WITH DUPLICATES HERE while($row_match_passcode = mysql_fetch_assoc($result_match_passcode)) { $match_first_initial = substr($row_match_passcode['name_first'],0,1); $match_last_initial = substr($row_match_passcode['name_last'],0,1); $match_dob = $row_match_passcode['dob']; if((strtolower($match_first_initial) == strtolower($first_initial)) && (strtolower($match_last_initial) == strtolower($last_initial)) && ($match_dob == $dob)) { $matched_subject = TRUE; break; } } if($matched_subject) { //subject record exists // use the given subject id $_SESSION['subject_id'] = $row_match_passcode['subject_id']; //see if there are responses in the response table associated with the subject ID //if so, use "find_old_session" to recover the old session //if recovering an old session, the current session will remained associated with a //tmp_ subject ID, but this should be OK. //if there are no pre-existing responses, update the current session ID and responses with the subject ID if($start_session) { if(responses_exist_for_sub($_SESSION['subject_id'],$_SESSION['response_table'])) { $sess_status = find_old_session($_SESSION['subject_id'],TRUE); if($sess_status == "not_found") { report_error_form("Error resuming session","subidgen_passcode_initials_dob.php"); } } else { // add the subject id to the session information $sql_update_session = sprintf("update session set subject_id = %s, php_session_id=%s where session_id = %s ", GetSQLValueString($_SESSION['subject_id'],"text"), GetSQLValueString($_COOKIE[$QPI_SESSION_NAME],"text"), GetSQLValueString($_SESSION['session_id'],"int")); mysql_update($sql_update_session); // update any responses that have already been given in the experiment's response table $sql_update_responses = sprintf("update %s set subject_id = %s where session_id = %s ", $_SESSION['response_table'], GetSQLValueString($_SESSION['subject_id'],"text"), GetSQLValueString($_SESSION['session_id'],"int")); mysql_update($sql_update_responses); } } //end start session } //end matched subject else { printf("

%s %s

",LANGUAGE_TEXT_ERROR_INFO_NOMATCH,LANGUAGE_TEXT_ERROR_PLEASE_TRY_AGAIN); } } ?>