I can send data to a php script.
■ My Pure Basic Code.
Code: Select all
XIncludeFile "D:\Applications\Pure Basic\Pb2Web\p2w.pbi"
P2W_Converter_SetProfile("pb2webtest")
Global Sortie.s, run, user.s, location.s
Enumeration
#mainform
#fmuser
#fmlocation
#button
EndEnumeration
P2W_Converter_Begin_Raw
;$('body').attr("id", "w_" + mainform);
P2W_Converter_End_Raw
Procedure DataRead()
EndProcedure
Procedure DataRecord()
Protected user.s
Protected location.s
user = GetGadgetText(#fmuser)
location = GetGadgetText(#fmlocation)
P2W_Converter_Begin_Raw
;$.ajax({
; type: "GET",
; url: 'test.php',
; data: { action: "post", user: user, location: location }
;});
P2W_Converter_End_Raw
SetGadgetText(#fmuser, "")
SetGadgetText(#fmlocation, "")
MessageRequester("Information", "Updated.")
EndProcedure
Procedure WindowShow()
P2W_Converter_Begin_Comment
OpenWindow(#mainform, 0,0, 800, 600,"")
P2W_Converter_End_Comment
TextGadget(#PB_Any, 20, 20, 80, 25, "User")
StringGadget(#fmuser, 100, 20, 200, 22, "")
TextGadget(#PB_Any, 20, 50, 80, 25, "Location")
StringGadget(#fmlocation, 100, 50, 200, 22, "")
ButtonGadget(#button, 310, 20, 80, 22, "Click Here")
TextGadget(#PB_Any, 20, 150, 500, 22, "Proudly powered by Pure Basic & PB2Web")
BindGadgetEvent(#button, @DataRecord())
EndProcedure
WindowShow()
P2W_Converter_Begin_Comment
Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
P2W_Converter_End_Comment
■ My PHP Code (
test.php).
For this test: Create a text file and add a user name and its location.
Code: Select all
<?php
if(isset($_GET['action']))
{
$file = "users.txt";
$crlf= "\r\n";
if($_GET['action']=='post' AND isset($_GET['user']) AND isset($_GET['location']))
{
file_put_contents($file, $_GET['user']."|".$_GET['location'].$crlf, FILE_APPEND | LOCK_EX);
}
}
echo "test";
?>

I do not know how to use Ajax & pure basic to retrieve and read the data.