繁体   English   中英

POST未定义索引php

[英]Undefined index php by POST

我有我的ppf.php文件:

它有一个包含一些项目的表格,我在其中显示数据库中的数据,它的工作原理我没有问题。

<form name="pagar"  method="post" action="updaterecord.php">
<input type="text" name="num_paciente" size=40 maxlength=40 readonly value="<?php echo $fila['num_paciente']; ?>">// Here I show data from my data base // it works.
<input name="monto"  size=40 maxlength=40 type="text"  value="" required />
<textarea id="concepto" name="concepto" rows="5" cols="58" required></textarea>
..more input fields
 <input align="middle" type="submit" value="paga">
</form>

问题是

ppf.php有一个提交按钮,我的表单发送到updaterecord.php 在updaterecord.php中,我需要接收ppf.php所有值来更新数据库中的表:

<?php
$num_paciente=$_POST['num_paciente'];
$monto=$_POST['monto'];
$concepto=$_POST['concepto'];

$updater="UPDATE op SET monto = '$monto', concepto='$concepto', status='PAGADO' where num_paciente='".$num_paciente."'";
mysql_query($updater,$con)or die (mysql_error());
?>

它不起作用:我看到了:

Notice: Undefined index: num_paciente in C:\xampp\htdocs\...\updaterecord.php on line 16    
Notice: Undefined index: monto in C:\xampp\htdocs\...\updaterecord.php on line 17    
Notice: Undefined index: concepto in C:\xampp\htdocs\...\updaterecord.php on line 18

我该如何解决这个问题? 谢谢

除了@Barry的答案,您的查询还必须按以下方式更正:

$updater="UPDATE op SET monto = '".$monto."', concepto='".$concepto."', status='PAGADO' where num_paciente='".$num_paciente."'";

我再次阅读了您的代码,请注意文本区域,更改此内容:

<input type="text" name="num_paciente" size=40 maxlength=40

<input type="text" name="num_paciente" size="40" maxlength="40"

采用

<form method="post">

发送带有后操作的表单值。 默认方法是“ get”。 您还可以在PHP脚本中使用$_GET获取值。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM