Send Datas From Ipad and save over Apache+PHP on a Windows-Folder as INI-File: Difference between revisions
Jump to navigation
Jump to search
Kaplanerkan (talk | contribs) |
Kaplanerkan (talk | contribs) |
||
Line 70: | Line 70: | ||
......... | ......... | ||
......... | ......... | ||
Call ReadDatasFromSQLandSaveAsArray | |||
'returns => | |||
' tmpBestellung[] | |||
' orderCounter as int | |||
........... | |||
........... | |||
Rem Ini-File Content | |||
backToString = "[BON];" & _ | |||
"Kellner=" & tmpKellner[1] & ";" & _ | |||
"Cheff=1;" & _ | |||
"Tisch="& TischNo & ";" & _ | |||
"Anzahl=" & orderCounter & ";" | |||
For i=0 To orderCounter | |||
backToString += "Bestell_" & (i) & "=" & tmpBestellung[i] | |||
Next | |||
...... | |||
..... | |||
req=Ajax("http://192.168.3.189/Kasse/save.php","POST",IniFileName & "," & backToString) | |||
If req.status=200 Then 'success | |||
End Function | End Function |
Revision as of 21:11, 28 May 2013
In this example I will show how I send my data from ipad on Windows-PC and later save it as INI-File to a windows-folder.
save.php
save.php is saved into xampp-Ordner d:\xammp\htdocs\Kasse\save.php
This file gets the datas through POST, parses it after each semicolon, and then save the datas as ini-file under the directory "C:\Kasse10\Bestellungen\"
From Ipad ist send via POST (filename , lines separated with ";")
=> FILE_NAME_TO_SAVED_Ini-File + , + Lines1_for_Ini;Line2_for_Ini;Line3_for_Ini;Line3_for_Ini
<?php header('Access-Control-Allow-Origin: *'); //header("Access-Control-Allow-Credentials", "true"); ini_set('display_errors','1'); $backup_dir = "c:\\Kasse10\\Bestellungen\\"; // Get the data from the client. $myText = file_get_contents('php://input'); /* buradan */ $tmp = explode(",",$myText); $myFile = $tmp[0]; $myText = str_replace(";","\r\n",$tmp[1]); /* buraya kadar */ $myFile= $backup_dir . $myFile; echo "Data received from Device:<br>" . $myText; echo "<p>Writing data to " . $myFile; $f = fopen($myFile, 'w') or die("can't open file"); fwrite($f, $myText); fclose($f); ?>
Ini-Files(Ordering Files)
This files contains information for order and later by a module on Windows-PC that I have written with Visual Studio 2008, edited and printed.
My ini-files looks like this:
[BON] Kellner=5 Cheff=1 Tisch=17 Anzahl=4 Bestell_0=1*301<mit Eis, Ohne Zitrone>0 Bestell_1=1*302<mit Zitrone>0 Bestell_2=1*404<Ohne Eis>0 Bestell_3=1*503<Ohne Tomaten>0 Bestell_4=1*607<>0
NSAppStudio Sample Code
Function btnSave_ontouchstart() ........... ........... Call FileNameToSave("1") 'return => IniFileName = localStorage.FileNameForIniFile Call FindWaiterName 'return => waiterName = localStorage.LogedWaiterName Call FindTableNo 'return => TischNo = localStorage.TischNo ......... ......... Call ReadDatasFromSQLandSaveAsArray 'returns => ' tmpBestellung[] ' orderCounter as int ........... ........... Rem Ini-File Content backToString = "[BON];" & _ "Kellner=" & tmpKellner[1] & ";" & _ "Cheff=1;" & _ "Tisch="& TischNo & ";" & _ "Anzahl=" & orderCounter & ";" For i=0 To orderCounter backToString += "Bestell_" & (i) & "=" & tmpBestellung[i] Next ...... ..... req=Ajax("http://192.168.3.189/Kasse/save.php","POST",IniFileName & "," & backToString) If req.status=200 Then 'success End Function