2012-11-17 166 views
1

您能否帮我解决这个问题?我一直在试图在文本框中发布内容,并试图使用PHP'echo'来显示它,但它一直显示“未定义索引”,并且不会发布文本框的内容。下面的代码:发布索引时发生PHP错误

<?php 

if (isset($_POST['updateaccount'])) { 

$accountType = $_POST['typeBox']; 

echo $accountType; 
} 
?> 
<form method="POST" action="<?php echo $_SERVER['PHP_SELF'];?>"> 
<table> 
<tr> 
    <td><strong>Account Type<strong></td> 
    <td><input type="text" name="typeBox" value="This is a test." disabled="true"></td> 
</tr> 
<tr> 
    <td></td> 
    <td><input type="submit" name="updateaccount" value="Update Account"></td> 
</tr> 
</table> 
</form> 

每当我尝试提交表单,它说:

公告:未定义指数:用C typeBox:\ XAMPP \ htdocs中\ cel1rcfc \上线test.php的5

回答

3

由于您设置了属性disabled="true",因此禁用的输入元素将不会发布到服务器端。

+0

谢谢!你真的救了我的命! –

+0

@ JianCarloV.Rubio将其标记为最佳答案。 –

0

你标记的输入为“禁用”:

<input type="text" name="typeBox" value="This is a test." disabled="true"> 

所以它没有被提交。但是,提交按钮(updateaccount)已启用,所以您在顶部的支票通过。

0

它是你已经设置属性disabled="true"为文本框的原因删除disabled="true"以得到你想要的结果。

这样

<input type="text" name="typeBox" value="This is a test" /> 
0

您应该删除属性disabled="true",使其正常工作。