2016-08-16 100 views
0

我正在做一個評論頁面,用戶將在其中選擇評分並在文本區域中撰寫評論。我想要捕獲登錄用戶的用戶ID,給出的評論的imageid,用戶選擇的評分以及用戶輸入的文本。現在的問題是,點擊提交後,它不會重定向到我的捕獲頁面。PHP將變量傳遞到下一頁

window.location.href = "captcha.php?imageid='.$imageID.'&userid='.$userID.'&rating="+rating+"&text="+text"; 

這是Javascript在PHP重定向

<form name="form1" method="post" onSubmit = "return insertReview();"> 

這是我的表單代碼

+0

添加insertreview(); – jophab

+0

<腳本類型= 「文本/ JavaScript的」> 功能insertReview() { \t如果(document.form1.userreview.value.length> 500) { 警報( 「請使用小於500個字」); 返回false; } else { \t var s = document.getElementById(「rating」); \t var rating = s.options [s.selectedIndex] .text; \t var textarea = document.getElementById(「userreview」).value; \t \t window.location.href =「? '$用戶ID 'captcha.php圖像標識='。$圖像標識' 與用戶ID =等級= 「+等級+」 &文本= 「+文字」; }} – user3567749

+0

我認爲你可以在captcha.php中做這個驗證事情,而不是在javascript中做這個 – jophab

回答

0
<form name="form1" method="post" action = "captcha.php"> 

在captcha.php您可以訪問形式的網頁內容的代碼使用$ _POST數組。 在那裏驗證和過濾數據。如果出現錯誤,給出錯誤信息並重定向到前一頁