在提交表單時遇到未定義的變量問題。請幫助PHP中未定義變量,表單提交
有人可以告訴我我錯過了什麼嗎?
我打算調用函數'process_input'的表單提交,並在裏面的過程輸入我得到的ip/uid/pwd的細節。
$.ajax({
type : 'POST',
url : 'post_process.php',
data : {
func : 'process_input'
},
}).done(function(data) {
// show the response
$("#response").html(data);
PHP
if (isset ($_POST ['func']) && ! empty ($_POST ['func'])) {
$func = trim ($_POST ['func']);
switch ($func) {
case 'process_input' :
process_input();
break;
..........
}
}
function process_input() {
header ('Content-Type: text/html; charset=utf-8');
if (isset ($_POST ['ip']) && ! empty ($_POST ['ip'])) {
$ip = trim ($_POST ["ip"]);
}
if (isset ($_POST ['uid']) && ! empty ($_POST ['uid'])) {
$uid = trim ($_POST ["uid"]);
}
if (isset ($_POST ['pwd']) && ! empty ($_POST ['pwd'])) {
$pwd = trim ($_POST ["pwd"]);
}
echo "$ip $uid $pwd <br>";
...
}
說明:未定義變量:ip的在上線41
所有變量($ip
$uid
$pwd
)來作爲未定義
你變得未定義哪個變量? – 2014-10-16 13:55:40
$ ip,$ uid,$ pwd變量。 – angshuman 2014-10-16 13:56:43
您是否收到任何錯誤?在打開'<?php tag error_reporting(E_ALL)'後立即將錯誤報告添加到文件頂部。 ini_set('display_errors',1);' – 2014-10-16 13:59:19