Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // Connects to the db
- $dbconn = new mysqli("localhost", "i01qbpdb_locusja", "ninfa2812", "i01qbpdb_locus");
- if($dbconn->connect_error){
- die("Connessione fallita " . $dbconn->connect_error);
- }
- // Gets the data relevant to the "act"
- $act = $_REQUEST['act'];
- $rows = array();
- $sqlNUOVO = "";
- $select = 'no';
- switch($act){
- case 'CHKUSER':
- $pwd = $_REQUEST['password'];
- $sqlNUOVO = "select cognome from public.user where username = '" . $_REQUEST['user']. "' and password = '$pwd'";
- $consulta=pg_exec($dbconn, $sqlNUOVO);
- $numregs=pg_numrows($consulta);
- if( $numregs == 0 ){
- $rows['result'] = '0';
- }else{
- $rows['result'] = pg_result($consulta,0,'cognome');
- }
- /*
- scrive il LOG
- */
- $sqlNUOVO = "insert into logaccessi values ('" . $_REQUEST['user']. "',now(),'LOGON')";
- $consulta=pg_exec($dbconn, $sqlNUOVO);
- break;
- // If we need to find the beacon ...
- case 'GET_BEACON':
- $sqlNUOVO = "SELECT `description`,`text`,`soundUrl` FROM `beacon` WHERE beaconId = '" . $_REQUEST['beaconId'] ."'";
- $select = 'exec';
- break;
- default:
- ;
- }
- if($select == 'exec'){
- // Asks for the result of the query
- $result = $dbconn->query($sqlNUOVO);
- if($result->num_rows > 0){
- $rows = array();
- while($r = $result->fetch_assoc()){
- $rows[] = $r;
- }
- }
- }
- $json = json_encode($rows);
- print $json;
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement