Hola! pues yo estoy en algo parecido haber si me pueden ayudar, resulta que tengo este link
http://gpsguate.esy.es/phpproject/libro.html , pide nombre y correo para almacenarlo en una DB en un servidor, pues yo lo que necesito es guardar el nombre y correo enviado desde arduino uno + sim900.
Adjunto el codigo de arduino
/*Note:
send a http request to the website
The microcontrollers Digital Pin 7 and hence allow unhindered
communication with GPRS Shield using SoftSerial Library.
IDE: Arduino 1.0 or later
#include <SoftwareSerial.h>
#include <String.h>
SoftwareSerial mySerial(7, 8);
void setup()
{
mySerial.begin(19200); // the GPRS baud rate
Serial.begin(19200); // the GPRS baud rate
delay(500);
}
void loop()
{
if (Serial.available())
switch(Serial.read())
{
case 'h':
SubmitHttpRequest();
break;
}
if (mySerial.available())
Serial.write(mySerial.read());
}
///SubmitHttpRequest()
///this function is submit a http request
///attention:the time of delay is very important, it must be set enough
void SubmitHttpRequest()
{
mySerial.println("AT+CSQ");
delay(100);
ShowSerialData();// this code is to show the data from gprs shield, in order to easily see the process of how the gprs shield submit a http request, and the following is for this purpose too.
mySerial.println("AT+CGATT?");
delay(100);
ShowSerialData();
mySerial.println("AT+SAPBR=3,1,\"CONTYPE\",\"GPRS\"");//setting the SAPBR, the connection type is using gprs
delay(1000);
ShowSerialData();
mySerial.println("AT+SAPBR=3,1,\"APN\",\"internet.ideasclaro\"");//setting the APN, the second need you fill in your local apn server
delay(4000);
ShowSerialData();
mySerial.println("AT+SAPBR=1,1");//setting the SAPBR, for detail you can refer to the AT command mamual
delay(2000);
ShowSerialData();
mySerial.println("AT+HTTPINIT"); //init the HTTP request
delay(3000);
ShowSerialData();
mySerial.println("AT+HTTPPARA=\"URL\",\"http://gpsguate.esy.es/phpproject/agrega.php\"");// setting the httppara, the second parameter is the website you want to access
delay(2000);
ShowSerialData();
mySerial.println("AT+HTTPACTION=0");//submit the request
delay(10000);//the delay is very important, the delay time is base on the return from the website, if the return datas are very large, the time required longer.
//while(!mySerial.available());
ShowSerialData();
mySerial.println("AT+HTTPREAD");// read the data from the website you access
delay(300);
ShowSerialData();
mySerial.println("");
delay(100);
}
void ShowSerialData()
{
while(mySerial.available()!=0)
Serial.write(mySerial.read());
}
Lo que me muestra el monitor
AT+CSQ
+CSQ: 19,0
OK
AT+CGATT?
+CGATT: 1
OK
AT+SAPBR=3,1,"CONTYPE","GPRS"
OK
AT+SAPBR=3,1,"APN","internet.ideasclaro"
OK
AT+SAPBR=1,1
ERROR
AT+HTTPINIT
ERROR
AT+HTTPPARA="URL","http://gpsguate.esy.es/phpproject/agrega.phpAT+HTTPACTION=0
OK
+HTTPACTION:0,200,123
AT+HTTPREAD
+HTTPREAD:123
Registro guardado exitosament
//Apesar que dice registro guardado exitosamente los registros los deja en blanco.
El codigo de agrega.php
<?php
//conexión a la base de datos
$con = mysqli_connect("xxxx", "xxxx", "xxxxx", "xxxxxxxx");
if (mysqli_connect_errno()){
echo "No se pudo conectar a la base de datos" . mysqli_connect_error();
}
//obtiene valores del formulario
$nombre = mysqli_real_escape_string($con, $_POST["nombre"]);
$correo = mysqli_real_escape_string($con, $_POST["correo"]);
//insertamos los valores del formulario en nuestra bd
$sql = "INSERT INTO tabla1 (nombre, correo)
VALUES ('$nombre', '$correo')";
if (!mysqli_query($con,$sql)) {
die('Error: ' . mysqli_error($con));
} else{
echo "Registro guardado exitosamente";
}
?>
<META HTTP-EQUIV="REFRESH" CONTENT="1;URL=http://gpsguate.esy.es/phpproject/listar.php">
El archivo listar da un listado de los datos de la DB y luego regresa a la pagina principal de libro.html.
Me podrian ayudar de como seria el codigo correcto en php para que guarde en la base de datos?? de antemano muy agradecido.
PD: Intente conectarme directamente con la DB pero ese hosting no permite hacer eso.