Post data to form via html5

How can i post some data to a php form,  from the html5 build online

name
lastname
email

thankyou

<!DOCTYPE html>

    <html lang=“en”>
    <head>
    <meta charset=“UTF-8”>
    <title>Add Record Form</title>
    </head>
    <body>
    <form action=“insert.php” method=“post”>
        <p>
            <label for=“firstName”>First Name:</label>
            <input type=“text” name=“firstname” id=“firstName”>
        </p>
        <p>
            <label for=“lastName”>Last Name:</label>
            <input type=“text” name=“lastname” id=“lastName”>
        </p>
        <p>
            <label for=“emailAddress”>Email Address:</label>
            <input type=“text” name=“email” id=“emailAddress”>
        </p>
        <input type=“submit” value=“Submit”>
    </form>
    </body>
    </html>

You would use the network.request() API. See: http://docs.coronalabs.com/api/library/network/request.html#http-post-with-custom-headers

Instead of this line:

local body = "color=red&size=small"

change it to something like (assuming you have variables named firstName, lastName, and emailAddress):

local function urlencode( str )&nbsp; &nbsp; if (str) then &nbsp; &nbsp; &nbsp; &nbsp; str = string.gsub (str, "\n", "\r\n") &nbsp; &nbsp; &nbsp; &nbsp; str = string.gsub (str, "([^%w])", &nbsp; &nbsp; &nbsp; &nbsp; function( c ) return string.format ("%%%02X", string.byte( c ) ) end) &nbsp; &nbsp; &nbsp; &nbsp; str = string.gsub (str, " ", "+") &nbsp; &nbsp; end &nbsp; &nbsp; return str&nbsp; &nbsp;&nbsp; end local body = "firstname=" .. urlencode(firstName) .. "&lastname=" .. urlencode(lastName) .. "&email=" .. urlencode(emailAddress)

You should always URL encode parameters being sent to a web form. Then on the network.request() call, just change out the URL.

Rob

thanks so much

You just know about getter and setter.

You would use the network.request() API. See: http://docs.coronalabs.com/api/library/network/request.html#http-post-with-custom-headers

Instead of this line:

local body = "color=red&size=small"

change it to something like (assuming you have variables named firstName, lastName, and emailAddress):

local function urlencode( str )&nbsp; &nbsp; if (str) then &nbsp; &nbsp; &nbsp; &nbsp; str = string.gsub (str, "\n", "\r\n") &nbsp; &nbsp; &nbsp; &nbsp; str = string.gsub (str, "([^%w])", &nbsp; &nbsp; &nbsp; &nbsp; function( c ) return string.format ("%%%02X", string.byte( c ) ) end) &nbsp; &nbsp; &nbsp; &nbsp; str = string.gsub (str, " ", "+") &nbsp; &nbsp; end &nbsp; &nbsp; return str&nbsp; &nbsp;&nbsp; end local body = "firstname=" .. urlencode(firstName) .. "&lastname=" .. urlencode(lastName) .. "&email=" .. urlencode(emailAddress)

You should always URL encode parameters being sent to a web form. Then on the network.request() call, just change out the URL.

Rob

thanks so much

You just know about getter and setter.