Guest User

Untitled

a guest
Aug 25th, 2018
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.76 KB | None | 0 0
  1. <?php
  2. include('connection.php');
  3.  
  4. if($_REQUEST['_username'] == null ||$_REQUEST['_password'] == null ||  $_REQUEST['_nomeBD'] == null)
  5. {
  6.    $output =  array ('ERRO' => '2');
  7.    print(json_encode($output));
  8. }
  9. else
  10. {
  11.     $user = $_REQUEST['_username'];
  12.     $pw = $_REQUEST['_password'];
  13.     $bdnome = $_REQUEST['_nomeBD'];
  14.  
  15.     $query = "SELECT _username,_password FROM acessos WHERE _username = $user AND _password = $pw";
  16.     $result = pg_query($connect, $query)
  17.         or die("<b>Não foi possivel encontrar os dados na BD:</b><br><br> '$php_errormsg'</br></br>");
  18.  
  19.     if(pg_fetch_assoc($result) > 0)
  20.     {
  21.            $output =  array ('ERRO' => '3');
  22.            print(json_encode($output));
  23.            
  24.             if ($_REQUEST['_titulo'] == null || $_REQUEST['_especie'] == null || $_REQUEST['_data_ocorrencia'] == null ||  $_REQUEST['_latitude'] == null || $_REQUEST['_longitude'] == null)
  25.             {
  26.                 $output =  array ('ERRO' => '1');
  27.                 print(json_encode($output));
  28.             }
  29.             else
  30.             {
  31.                 $sql= pg_query($connect, "INSERT INTO $bdnome (_titulo,_especie,_actividade,_data_ocorrencia,_latitude,_longitude) VALUES
  32.                ('".$_REQUEST['_titulo']."','".$_REQUEST['_especie']."','".$_REQUEST['_actividade']."','".$_REQUEST['_data_ocorrencia']."','".$_REQUEST['_latitude']."','".$_REQUEST['_longitude']."')")
  33.                 or die("<b>Não foi possivel introduzir os dados na BD:</b><br><br> '$php_errormsg'</br></br>");
  34.  
  35.                 $output =  array ('ERRO' => '0');
  36.                 print(json_encode($output));
  37.             }
  38.     }
  39.     else
  40.     {
  41.             $output =  array ('ERRO' => '2');
  42.             print(json_encode($output));
  43.     }
  44. }
  45. pg_close($connect);
  46. ?>
Add Comment
Please, Sign In to add comment