RE: [PHP] error Undefined index:
| From: | Romero, Fernando | Date: | Wed, 28 Mar 2018 15:15:28 +0000 |
| Subject: | RE: [PHP] error Undefined index: | ||
| References: | 1 2 3 4 5 6 7 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-326429@lists.php.net to get a copy of this message | ||
-----Mensaje original-----
De: Richard [mailto:inbound-lists-php@listmail.innovate.net]
Enviado el: miércoles, 28 de marzo de 2018 11:30 a. m.
Para: php-general@lists.php.net
Asunto: Re: [PHP] error Undefined index:
> Date: Wednesday, March 28, 2018 14:13:22 +0000
> From: Alejandro Michelin Salomon <amichelins@hotmail.com>
>
> Hi.
>
>
> Change FROM
>
> $empresa = $_POST['empresa'];
>
>
> TO
>
> // To have a default value
>
> $empresa = ( isset( $_POST['empresa'] ) ) ? $_POST['empresa'] :
> '';
>
>>
>> if ( $_POST ) {
>> $result=pg_query("SELECT empresa, sum(valor) valor FROM trabajos
>> WHERE empresa='$empresa' and to_char(fecha, 'TMMONTH')::varchar =
>> '$mes' and date_part('year', fecha)= '$anio'
>> group by empresa");
>> $registros= pg_num_rows($result);
>>
Do not ignore that using a $_POST value, without sanitizing it first is, as has been pointed out, a
very serious sql injection vulnerability vector. You might have fixed the "Undefined
index"
issue, but this code (as previously presented) isn't something that should be put into use.
--
PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
I solved it by adding the imput:
<select name = "empresa" onchange="fun_lista();">
Thank you all