Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: EthernetInterface TMP175 mbed-rtos mbed
Fork of HTTP_POST by
Diff: cgi-bin/restsql.txt
- Revision:
- 9:dffb514cde17
- Child:
- 10:3a38ba20cb57
diff -r 2ecceb32e68b -r dffb514cde17 cgi-bin/restsql.txt
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cgi-bin/restsql.txt	Mon Jun 08 19:09:11 2015 +0000
@@ -0,0 +1,39 @@
+#!/bin/bash
+#
+#   Mittels HTTP POST in MySQL Schreiben
+
+# HTTP Header fuer Client
+echo "Content-type: text/plain"
+echo ""
+
+#
+### POST
+#
+if [ "$REQUEST_METHOD" = "POST" ]
+then
+    # Zerlegt den Querystring in Einzelteile
+    saveIFS=$IFS
+    IFS='=&'
+    parm=(`cat -`)
+    IFS=$saveIFS
+
+    printf "write to SQL Database: "
+    FIELDS=""
+    DATA=""
+    for (( index = 0; index < ${#parm[@]}; index += 2 ))
+    do
+        if  [ ${index} -gt 0 ]
+        then
+            FIELDS=${FIELDS}","
+            DATA=${DATA}","
+        fi
+        FIELDS=${FIELDS}${parm[index]}
+        DATA=${DATA}${parm[index+1]}
+    done
+    SQL="INSERT INTO data( ${FIELDS} ) VALUES( ${DATA} );"
+    echo $SQL
+    mysql -uroot -padmin sensoren <<EOF
+${SQL}
+EOF
+
+fi
    