調用PHP的情況下唯一安全的ID從數據庫中收集它們被呈現到客戶端之前。如何我一直在使用一個公式從另一個PHP的情況下
然而,正如我的代碼長大複雜,我掉進這個陷阱:我有兩個獨立的情況下返回JSON需要使用相同的ID。因爲我的安全功能在每個執行過程中產生一個唯一的散列和密鑰,所以從一個案例收集的散列ID不能在需要使用它的另一箇中加密。因此,作爲一個解決方案,我認爲發送哈希ID從第一種情況下收集回第一種情況下再次,解密那裏,然後以某種方式把它傳遞給其他情況下沒有客戶端永遠不會有機會一睹真實身份。
所有的代碼做工精細,我的問題是匹配的是在這種情況下破門,這是一個簡單的客戶端觸發循環之前也發回數據的第二情況下使用第一種情況下得出的ID。我提供代碼,以防你會問。問題只是在兩個單獨的php情況下將相同的id與不同的唯一散列值進行匹配。對不起,如果我把它比它應該更復雜。
這是我用來填充下拉選擇的第一種情況。
case "tutorRefresh": $tutorSelectSql = "SELECT id, tname, tsurname FROM tutors"; $tutorSelectQry = pg_query($tutorSelectSql); while($row = pg_fetch_array($tutorSelectQry)){ $id = lockPandoraBox($row['id']);//encrypt the id $response[] = array("id" => $id, "tname" => $row['tname'], "tsurname" => $row['tsurname']); }; if(isset($response)){ echo json_encode($response); } else { $response = array("val" => 0); echo json_encode($response); } break;
這是由更新表數據的第二情況下使用的功能,因爲實在是太漫長而複雜的一個問題,它張貼在這裏的所有,我只是共享代碼的相關部分。我必須將上面代碼中加密的id與此處加密的id相匹配,因爲此代碼填充表格,而上面的代碼只是填充下拉選擇。
$crypted = lockPandoraBox($row["appid"]); $tutorID = lockPandoraBox($row["tutorid"]);//encrypting id $clientID = lockPandoraBox($row["clientid"]);//same method for another id, ignore this. $fApp["hours"][] = array("recId" => $crypted, "hour" => $row["hour"], "tutor" => $tutorArr["tname"]." ".$tutorArr["tsurname"], "tutorId" => $tutorID,// id that I need to use "client" => $clientArr["cname"]." ".$clientArr["csurname"], "clientId" => $clientID, "department" => $dept, "degree" => $deg, "purpose" => $purposeArr["pname"], "purposeId" => $row["purpose"], "contact" => $clientArr["cgsm"], "email" => $clientArr["cemail"], "tutorAbsCheck" => $tutorAbsArray["id"], "tutorAbsReason" => $tutorAbsArray["reason"], "clientAbsCheck" => $clientAbsArray["id"], "clientAbsReason" => $clientAbsArray["reason"] ); /* */ } return json_encode($fApp); }
最後,這是我的主要頁面的代碼這觸發我需要的情況下點擊事件功能工作。它只是改變匹配點擊記錄的選擇框的選擇。它從表格中選擇id並嘗試將其與選擇框中的id相匹配。提前致謝。 (「#tutorEdit」)。val(dayData [「hours」] [$(el.currentTarget).attr(「key」)]。tutorId).trigger(「change」);
我已閱讀剛剛開頭兩段,並認爲 - 也許你正在尋找會話變量? –
會,我根本不知道他們。我會檢查出來的。 – Ahmet
可能重複:http://stackoverflow.com/questions/4015729/php-session-start –