0
votes

i am designing an rfid attendance system with arduino uno, esp8266-01 wifi module, and a rfid reader. The task is to read a rfid card and to send its unique id number to a webpage (coded in php) which stores the data in a database. We sent at commands to the module from arduino ide serial monitor through a uno board. We used Serial_ophttp POST method first to send the read rfid number to the webpage. As that attempt was a failure we tried using GET method. But neither of those methods worked.

    <?php
    error_reporting(E_ALL ^ E_DEPRECATED);
    $dbhost = 'localhost';
    $dbuser = 'root';
    $dbpass = '';
    $conn = mysql_connect($dbhost, $dbuser, $dbpass);
    if(! $conn ) {
    die('Could not connect: ' . mysql_error());
    }
    $Data=$_GET['Data'];
    //$Data='Data test';
    echo "Data is :" . $Data;
    $sql = "INSERT INTO test_tab (Data) VALUES ('$Data')";
    mysql_select_db('robot');
    $retval = mysql_query( $sql, $conn );
    if(! $retval ) {
    die('Could not enter data: ' . mysql_error());
    }   
    echo "Entered data successfully\n";
    mysql_close($conn);
    ?>
1
what if you try to send data with the url. For exemple www.mysite.com/page.php?data1=value&data2=value2 you get them in the page.php by doing get['data1'] or get['data2']Thanatheos

1 Answers

0
votes

You are missing a few \r\n and the length you are giving to your AT+CIPSEND is incorrect.

Try sending this instead:

AT+CIPSEND=43\r\n
GET /test.php?Data=2\r\nHost:192.168.1.13\r\n\r\n

To send \r\n just hit Enter. Make sure that "Both NL & CR" is selected in your serial monitor. At the end, yes you hit Enter twice.

Here I am sending the value 2.

Here how I get the 43 length: You take the size of your GET (we have 49) and you subtract 1 for each \r or \n. Because they are just one character. So we have 49 - 6 = 43.

Please, make sure to try to send a value directly from the URL to verify that your PHP script is working fine. Fix any possible error before trying to send data through ESP8266.

Side Note: It is not recommended to use the API mysql, as it is deprecated and removed from new versions of php. See (http://php.net/manual/en/mysqlinfo.api.choosing.php)