Pages: [1]   Go Down
Author Topic: POSTing from site to SIM900 module  (Read 1663 times)
0 Members and 1 Guest are viewing this topic.
ਪੰਜਾਬ
Offline Offline
Edison Member
*
Karma: 12
Posts: 1593
Another year! Alone! :(
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Well I have successfully used the GPRS to uplift whatever I like and store it on my websites database whenever however I may like , but now I'm trying to mod the stuff and write some script etc to make the arduino receive stuff from my website , like say a button clicked  , whenever I put php along with the scripting the php does not work, the code is as follows:

Code:
<!DOCTYPE html>
<html>
<head>
<script>
var state
function on()
{
  state = document.getElementById('but1').value;
  document.getElementById('field2').value = state;
}
function off()
{
 
  state = document.getElementById('but2').value;
  document.getElementById('field2').value = state;
}
</script>
</head>
<body>

Field2: <input type="text" id="field2" />
<br /><br />
<input type='button' id="but1" onclick='on()' value='ON' />
<input type='button' id="but2" onclick='off()' value='OFF' />
<?php
             
echo "hashar";
             if (
state == "ON")
             {
               echo 
"on!";
             }
             if (
state == "OFF")
             {
               echo 
"off!";
             }  
?>


</body>
</html>

on the FIELD2: box shows and the two respective button also the scripting works but then nothing shows out of the php code.

Another point here is how I access the variables in scripting? I want to access the state variable
« Last Edit: October 02, 2012, 02:40:57 pm by NI$HANT » Logged

"Real Men can Accomplish  Anything"
-  Website  
- skype : nishants5  

ਫ਼ਤੇਹ ਕਰੂਂ !

Switzerland
Offline Offline
Faraday Member
**
Karma: 108
Posts: 5144
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

This is a PHP problem and has nothing to do with the Arduino! Ask in a PHP forum.

Hint anyway: PHP has no direct access to javascript variables, think about when and where PHP is executed, when and where javascript is executed.
Logged

ਪੰਜਾਬ
Offline Offline
Edison Member
*
Karma: 12
Posts: 1593
Another year! Alone! :(
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Actually Now I have made some progress, I have used AJAX request to shoot HTTP get requests and that code is working flawlessly:

An excerpt from the code showing HOW the get data is sent to the script myform.php in a Silent way that is not opening any windows or showing in the link the script file running:

Code:
var namevalue=encodeURIComponent(document.getElementById("but2").value)
mygetrequest.open("GET", "myform.php?name="+namevalue, true)
mygetrequest.send(null)

At the other side the myform.php receives the values correctly you can see at http://winacro.com/scriptGET.php

So now I want to send the clicks to my SIM900 module running using ATmega328, previously I did the following request code and was successful in loading the values to a database on my server BUT THE MAIN QUESTION HERE IS HOW I CAN DO IT IN THE OTHER WAY AROUND that is now to send values from my site to Arduino:

Code:
reading = analogRead(tempPin);
  tempC = reading / 9.31;
  mySerial.print("AT+HTTPPARA=\"URL\",\"http://winacro.com/script.php?tempC=");
  mySerial.print(tempC);
  mySerial.println("\"");
  delay(1000);
 
  ShowSerialData();
 
  mySerial.println("AT+HTTPACTION=1");//submit the request

I wanted to know I should I make the AT+HTTPPARA loaded as such I get the values from the clicks I make on that page.

EDIT: I further read into the SIM900 datasheet and what I read about is two commands that may work for me as follows:

1) AT+HTTPREAD=<data_len>,<byte size> , to be used when the  AT+HTTPACTION=0 or AT+HTTPDATA is executed , so where should I execute it above httpaction and httpdata or below, I mean simply where should I write it?

OR

2) AT+HTTPDATA=<size>,<time>,where in the code?
« Last Edit: October 05, 2012, 02:09:24 pm by NI$HANT » Logged

"Real Men can Accomplish  Anything"
-  Website  
- skype : nishants5  

ਫ਼ਤੇਹ ਕਰੂਂ !

Pages: [1]   Go Up
Jump to: