Re: error Undefined index:
| From: | Richard | Date: | Wed, 28 Mar 2018 14:30:27 +0000 |
| Subject: | Re: error Undefined index: | ||
| References: | 1 2 3 4 5 6 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-326428@lists.php.net to get a copy of this message | ||
> 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.