简体   繁体   中英

Undefined index php by POST

I have my ppf.php file:

it has a form with some items,where I show data from my database, it works i have no problem with it.

<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>

the problem is

ppf.php has a submit button, and my form is send to updaterecord.php . In updaterecord.php i need to receive all values of my ppf.php to update a table in my Database:

<?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());
?>

It doesn't work: and I see it:

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

How I can solve this problem? Thank you

In addition to the answer of @Barry, your query must be corrected as this:

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

I read again your code, please be careful to the textarea, change this:

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

to

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

Use

<form method="post">

to send the form values with a post action. The default method is "get". You can also get the values with $_GET in your php script.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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