2011-09-21 21 views
0

我有index.php,我有一個登錄表單:如何使用表單建立安全頁面傳輸?

<form method=post action="login.php" id="login"> 
<input type="text" size="16" maxlength="30" name="login" id="login_user" /> 
<input type="password" name="pass" id="login_pass"/> 
<input name="msubmit" type="submit" value="Login" /> 
</form> 

我怎樣才能確保表單會通過安全線處理?

我需要添加https://嗎?

<form method=post action="https://test.com/login.php" id="login" 

任何想法?

謝謝。

+1

您必須確保表單顯示在通過** https **提供的頁面上,而不僅僅是指向它。否則數據將以普通** http **發送。 – chelmertz

回答

1

是,最好的方法是指定https

<form method="post" action="https://domain.com/login.php" id="login"> 
    <input type="text" size="16" maxlength="30" name="login" id="login_user" /> 
    <input type="password" name="pass" id="login_pass" /> 
    <input name="msubmit" type="submit" value="Login" /> 
</form> 

即使index.php通過安全通道服務,這是很好的做法,對後行動明確指定https,因爲這是它發送請求通過線路傳輸敏感數據。但也建議僅通過https服務index.php

+1

假設你已經帶來並建立了一個ssl證書。 – 2011-09-21 22:02:09

+0

@Patrioticcow - 此外,作爲頁面一部分的每個下載元素(腳本,樣式表,圖像等)都需要使用「https」。 –

+0

我買了一個SSL證書,我的'index.php'沒有通過安全通道提供。 – Patrioticcow

0

使用https協議。同時將所有參數視爲tainted - 並讓PHP腳本以負責任的方式處理它們。

* I.e。解析(正則表達式)它們並在使用數據庫/命令行時必要時進行轉義*