Posted in

Exemple aplicació guardar recuperar

Exemple d’aplicació Android “guardar/recuperar” amb App Inventor de Google.

Elements

Programari

L’arxiu php encarregat de mostrar i guardar les dades online, en aquest cas en un fitxer txt, és el següent:

o$postUrl = $_SERVER["REQUEST_URI"]; 
o
oif(strpos($postUrl,'storeavalue')){ 
o  // Storing a Value
o
o  // Get that tag
o  $tag = trim($_REQUEST['tag']); 
o  // Get the value 
o  $value = trim($_REQUEST['value']); 
o
o  // In this example, output to a file, but could use MySQL, or anything
o  $myFile = "testFile.txt";
o  $fh = fopen($myFile, 'w') or die("can't open file");
o  fwrite($fh, str_replace('"', '', $value));
o  fclose($fh);
o
o} else { 
o  // Retrieving a Value
o
o  $tag = trim($_REQUEST['tag']); 
o
o  $myFile = "testFile.txt";
o  $fh = fopen($myFile, 'r');
o  $theData = fgets($fh);
o  fclose($fh);
o
o  if ($theData == "two times table") {
o$resultData = array("VALUE", $_REQUEST['tag'], array('1 x 2 = '=>2, '2 x 2 = '=>4, '3 x 2 = '=>6, '4 x 2 = '=>8, '5 x 2 ='=>10));
o  } else {
o$resultData = array("VALUE", $_REQUEST['tag'], array($theData));
o  }
o
o  $resultDataJSON = json_encode($resultData); 
o  echo $resultDataJSON; 
o
o} 

* La url d’aquest arxiu s’inclou a les propietats de TinyWebDB

Deixa un comentari

L'adreça electrònica no es publicarà. Els camps necessaris estan marcats amb *


The reCAPTCHA verification period has expired. Please reload the page.