2016-08-30 67 views
-2

我无法弄清楚,为什么这个非常简单的使用从形式不工作的投入测试..

<?php 

echo "TEST"; 

echo "<pre>" . print_r($_POST, true) . "</pre>"; 

if(isset($_POST['SubmitButton'])){ //check if form was submitted 
    $input = $_POST['inputText']; //get input text 
    echo "Success! You entered: ".$input; 
} 
?> 

<html> 
<body> 
<form action="" method="post"> 
    <input type="text" name="inputText"/> 
    <input type="submit" name="SubmitButton"/> 
</form> 
</body> 
</html> 

当我展示它表明,它是空的数组。当我在输入字段中输入内容并单击提交时,没有任何更改。

The demo page

如果任何人有一个想法,谢谢,我将非常感激。

enter image description here

+0

是您在提交时重新载入页面吗? PHP代码仅在页面加载 –

+0

时执行,当您按下提交按钮时会发生什么? –

+0

页面重新加载并且输入字段被重置。但没有任何内容存储在数组 – Miron

回答

0

2东西

提交按钮需要一个值= “东西”,然后更改

echo "<pre>" . print_r($_POST, true) . "</pre>"; 

echo "<pre>" . print_r($_POST) . "</pre>"; 

如果需要,您只需要在 “真”将其作为var返回,如

$blob = print_r($_POST, true); 
echo "<pre>" . $blob . "</pre>"; 
+1

*“SubmitButton需要一个值=”某事“” - - 这是错误的。 –

+0

你真的认为这是问题吗?真? – developerwjk

+0

if(isset($ _ POST ['SubmitButton'])){isset应该做什么没有值?注:成功!你输入了:“。$ input;不在图片 –