PC SOFT

FORUMS PROFESSIONNELS
WINDEVWEBDEV et WINDEV Mobile

Accueil → WINDEV 2024 → Simple example send data to php form
Simple example send data to php form
Débuté par Peter Muckle, 03 sep. 2015 18:13 - 3 réponses
Posté le 03 septembre 2015 - 18:13
Hi All,

I am still scratching my head as to how to send data from an Android app via httpsendform and a php site and wondered if someone could help.

I have a php form with 3 fields; UID, Name and photo, and a 'Save' button. This can be filled in directly online, eg www.mysite.com/TestTable_add.php

What code do I need to send the data from an Android app and save on the server? Also, what is the approach with images when uploading into a database, or into a folder with a reference on the database?

for example if the photo is going into an image field:

HTTPCreateForm("FORM")
HTTPAddParameter("FORM", "UID", "100")
HTTPAddParameter("FORM", "Name", "Test Name")
HTTPAddParameter("FORM", "Photo", "??????")
HTTPSendForm("FORM", "www.mysite.com/TestTable_add.php")

Is this correct? I'm not sure which IP address I should be using, for example.

Thanks

Pete
Posté le 03 septembre 2015 - 21:15
Hi Pete,

I think you better make a webservice then sent from the mobile app to the webservice and let the webservice do the saving .

regards

Allard
Posté le 04 septembre 2015 - 13:37
OK I have a very simple version working, using php and MSSQL

WM form with two fields (EDT_TestID and EDT_Name) and a 'send' button.

Button code:

nTestID is string = EDT_TestID
sName is string = EDT_Name

HTTPCreateForm("FORM")
HTTPAddParameter ("FORM", "TestID", nTestID)
HTTPAddParameter ("FORM", "Name", sName)
HTTPSendForm ("FORM", "www.website.com/data_input.php")



file called data_input.php at website.com:

<?
$objConnect = mssql_connect("server.com","user","password");
$objDB = mssql_select_db("databasename");
$strSQL = "INSERT INTO TestTable ";
$strSQL .="(TestID, Name) ";
$strSQL .="VALUES ";
$strSQL .="('".$_POST["TestID"]."','".$_POST["Name"]."') ";
$objQuery = mssql_query($strSQL);
if($objQuery)
mssql_close($objConnect);
?>