php - 未定义索引 : submission with html5

标签 php javascript mysql

Possible Duplicate:
PHP: “Notice: Undefined variable” and “Notice: Undefined index”

当我在页面上点击“提交”时,信息确实会进入数据库,但有些信息仍然未定义,而且我没有从 JavaScript 中的示例中获取退回数据。


注意:未定义索引:样本位于

<div id="have"><  id="<?php echo 'sample' ?>" onChange="calcnum()"width="500" 
     height="500" style="border:1pt solid black"></div>
      <input type="hidden" name="number" id="number" />
<form action="<?php echo $editFormAction; ?>" method="POST" name="form">
<input name="save" type="hidden"  value="<? echo $_POST['sample']?>" />
<input name="submit" type="submit" onChange="calcnum()" value="submit" />
<input type="hidden" name="MM_insert" value="savelayout" />
    </form>

和java -

    <script type="text/javascript">

  function calc()
   {

     if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
    xmlhttp=new XMLHttpRequest();
   }
    else
  {// code for IE6, IE5
   xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
    }

    val1 = document.getElementById("sample").value;


    xmlhttp.onreadystatechange=function()
               {
   if (xmlhttp.readyState==4 && xmlhttp.status==200)
{

  document.getElementById("sample").innerHTML=xmlhttp.responseText;
  document.getElementById("sample").value = xmlhttp.responseText;

}}
   }
 </script>

任何指示将不胜感激,谢谢:)

最佳答案

要修复未定义的错误,请更改以下内容:

<? echo $_POST['sample']?>

对此:

<? if (isset($_POST['sample'])) {echo $_POST['sample'];} ?>

关于php - 未定义索引 : submission with html5,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14310482/

相关文章:

javascript - 基于分层(父子)数据的数据驱动面包屑

php - 有没有办法一起运行 store_result 和 get_result

javascript - 如何停止在 Electron 应用程序上创建空日志目录

php - 由于 Configurations.PHP 文件无法访问网站而导致数据库错误

php - 如果语句在预期工作时未被执行

php - MySQL 数据库页面上的 URL 标题调用

php - Omnipay:使用 transactionId 与 transactionReference 是否有约定?

php - CakePHP 3 - 如何自动显示多个新实体的表单错误?

javascript - Python - 从 Instagram 视频中抓取观看次数,加载为 JSON 格式

javascript - jQuery Select Box 是裁剪的滚动 Pane