[Solved] Conversion to String

[Problem solved]
hi all guys..
well I got arduino uno r3 and ehternet shield, im trying with arduino as server and I have mount a HTML page here, my problem is I can't get a code from the html to var, look this:

const char id= const char(cliente.print("document.form1.user.value"));

im trying this
I want get a data becuase I maked a login.. then Im tryied to put some like JS and php but dont work that for me :confused:
anyway I tried to get the user and psw in this case how im experiment whit this just I put the "user" and I want to put the "user"(ID to login) and give to var "ID" but I know that I'm doing that so bad.. Im here for any solution I have 1 week trying to resolve this.

sorry for my english is not my primary language. for more info just call it and I can give you.. that's all thx!

[Solution]
in html code I used function "onclick" then can write in the link the user entered. inside arduino code have an IF:
int OPC = readString.indexOf("Log="); //Read the link to 'Log='
if(readString.substring(OPC,OPC+5)=="Log=T")
{ do something } //in this case write Index.html

thx for all help guys... so now I have a new problem :confused: ---> [Solved] don't load the code - Programming Questions - Arduino Forum

Have you looked at what the print() method for whatever class cliente is an instance of returns? It is most likely NOT something that can be meaningfully cast to a const char.

The cliente.read() method MIGHT be what you are needing to use.

PaulS:
Have you looked at what the print() method for whatever class cliente is an instance of returns? It is most likely NOT something that can be meaningfully cast to a const char.

The cliente.read() method MIGHT be what you are needing to use.

okay then I need try with: String id= String(cliente.read("value1")); or String id= String(cliente.read("document.form1.user.value"));
I'm right sure? or Im doing something wrong?

anyway Im tried with: String id= String(cliente.read("value1")) and sketch throw "no matching function for call to 'EthernetClient::read(const char [7]'" :confused:
I cant undesrtand that can you guide me a little please?

The read() method doesn't take any arguments. It knows where to read from. It returns the value that it read. You need to store those characters somewhere, until you know that you have read a whole packet.

Xendor:
I want get a data becuase I maked a login.. then Im tryied to put some like JS and php but dont work that for me :confused:
anyway I tried to get the user and psw in this case how im experiment whit this just I put the "user" and I want to put the "user"(ID to login) and give to var "ID" but I know that I'm doing that so bad.. Im here for any solution I have 1 week trying to resolve this.

There are two parts to the problem.

You need to design the page so that when the user enters the name+password and requests a login, the page submits the values in an HTTP request.

Then when receiving the HTTP request you need to parse the request to recognise that it is a login request and extract the name+password values that were submitted.

You should have no trouble finding existing examples of both parts, but the code you quoted doesn't look anywhere close so I suggest that you start by looking at how other people solve the problem.

PeterH:
There are two parts to the problem.

You need to design the page so that when the user enters the name+password and requests a login, the page submits the values in an HTTP request.

Then when receiving the HTTP request you need to parse the request to recognise that it is a login request and extract the name+password values that were submitted.

You should have no trouble finding existing examples of both parts, but the code you quoted doesn't look anywhere close so I suggest that you start by looking at how other people solve the problem.

well.. unfortunately I was struggling to find examples, that's why I came here as a last option, because I have run out of ideas, also the english is not my first language then I took longer to understand something.

Is there a section here in the forum that does use your language? There are many different places in this forum that do use other languages. I do believe that Google is multilingual, If it isn't let me know and I'll do something about it promptly.

Bob

Simple server test code that captures the contents of a text box and looks in it for info, and changes an arduino pin start.

//zoomkat 12-08-12
//get submit box code
//for use with IDE 1.0
//open serial monitor to see what the arduino receives
//use the \ slash to escape the " in the html or use a '
//address will look like http://192.168.1.102:84 when submited
//for use with W5100 based ethernet shields
//note that the below bug fix may be required
// http://code.google.com/p/arduino/issues/detail?id=605 

#include <SPI.h>
#include <Ethernet.h>

byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; //physical mac address
byte ip[] = { 192, 168, 1, 102 }; // ip in lan
byte gateway[] = { 192, 168, 1, 1 }; // internet access via router
byte subnet[] = { 255, 255, 255, 0 }; //subnet mask
EthernetServer server(84);; //server port

String readString; 

//////////////////////

void setup(){

  pinMode(5, OUTPUT); //pin selected to control
  //start Ethernet
  Ethernet.begin(mac, ip, gateway, subnet);
  server.begin();

  //enable serial data print 
  Serial.begin(9600); 
  Serial.println("server text box test1"); // so I can keep track of what is loaded
}

void loop(){
  // Create a client connection
  EthernetClient client = server.available();
  if (client) {
    while (client.connected()) {
      if (client.available()) {
        char c = client.read();

        //read char by char HTTP request
        if (readString.length() < 100) {

          //store characters to string 
          readString += c; 
          //Serial.print(c);
        } 

        //if HTTP request has ended
        if (c == '\n') {

          ///////////////
          Serial.println(readString); //see what was captured

          //now output HTML data header

          client.println("HTTP/1.1 200 OK");
          client.println("Content-Type: text/html");
          client.println();

          client.println("<HTML>");
          client.println("<HEAD>");
          client.println("<TITLE>Arduino GET test page</TITLE>");
          client.println("</HEAD>");
          client.println("<BODY>");

          client.println("<H1>HTML form GET example</H1>");

          client.println("<FORM ACTION='/' method=get >"); //uses IP/port of web page

          client.println("Pin 5 'on' or 'off': <INPUT TYPE=TEXT NAME='LED' VALUE='' SIZE='25' MAXLENGTH='50'>
");

          client.println("<INPUT TYPE=SUBMIT NAME='submit' VALUE='Change Pin 5!'>");

          client.println("</FORM>");

          client.println("
");

          client.println("</BODY>");
          client.println("</HTML>");

          delay(1);
          //stopping client
          client.stop();

          /////////////////////
          if(readString.indexOf("on") >0)//checks for on
          {
            digitalWrite(5, HIGH);    // set pin 5 high
            Serial.println("Led On");
          }
          if(readString.indexOf("off") >0)//checks for off
          {
            digitalWrite(5, LOW);    // set pin 5 low
            Serial.println("Led Off");
          }
          //clearing string for next read
          readString="";

        }
      }
    }
  }
}