Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- include('connection.php');
- if($_REQUEST['_username'] == null ||$_REQUEST['_password'] == null || $_REQUEST['_nomeBD'] == null)
- {
- $output = array ('ERRO' => '2');
- print(json_encode($output));
- }
- else
- {
- $user = $_REQUEST['_username'];
- $pw = $_REQUEST['_password'];
- $bdnome = $_REQUEST['_nomeBD'];
- $query = "SELECT _username,_password FROM acessos WHERE _username = $user AND _password = $pw";
- $result = pg_query($connect, $query)
- or die("<b>Não foi possivel encontrar os dados na BD:</b><br><br> '$php_errormsg'</br></br>");
- if(pg_fetch_assoc($result) > 0)
- {
- $output = array ('ERRO' => '3');
- print(json_encode($output));
- if ($_REQUEST['_titulo'] == null || $_REQUEST['_especie'] == null || $_REQUEST['_data_ocorrencia'] == null || $_REQUEST['_latitude'] == null || $_REQUEST['_longitude'] == null)
- {
- $output = array ('ERRO' => '1');
- print(json_encode($output));
- }
- else
- {
- $sql= pg_query($connect, "INSERT INTO $bdnome (_titulo,_especie,_actividade,_data_ocorrencia,_latitude,_longitude) VALUES
- ('".$_REQUEST['_titulo']."','".$_REQUEST['_especie']."','".$_REQUEST['_actividade']."','".$_REQUEST['_data_ocorrencia']."','".$_REQUEST['_latitude']."','".$_REQUEST['_longitude']."')")
- or die("<b>Não foi possivel introduzir os dados na BD:</b><br><br> '$php_errormsg'</br></br>");
- $output = array ('ERRO' => '0');
- print(json_encode($output));
- }
- }
- else
- {
- $output = array ('ERRO' => '2');
- print(json_encode($output));
- }
- }
- pg_close($connect);
- ?>
Add Comment
Please, Sign In to add comment