Loading ...
Sorry, an error occurred while loading the content.

39490Re: Transfer data from LB program to web page text box

Expand Messages
  • zoomkat
    Nov 1, 2009
      --- In libertybasic@yahoogroups.com, "Lorne Russell" <lorneokb@...> wrote:
      > Well after several exasperating hours I finally figured it out. I had to
      > label my webpage with the extension .php
      > then extract the serial number with <?php $serial=$_GET["serial] ?>
      > then insert the serial number in the textbox with value=<?php echo $serial;?>
      > Lorne

      LB is not well suited to operate on the server side of a web transaction. Most web servers transact with server CGI programs using stdin and stdout, which LB isn't well suited. Below is simple FreeBasic code example that when compiled can work with servers like Apache. For test purposes it sends back to the brouser the info that is passed either as a "get" or a "post". Code could be added in to process the info and return the desired result. As to registering software, there has been discussion in the just basic forum on how to register a program to a specific hard drive.

      '' Simple CGI example
      '' - return request back to client

      Dim As String method, request
      Dim As Integer length

      method = Environ("REQUEST_METHOD")

      Select Case Ucase(method)
      Case "HEAD"
      Print "Content-type: text/html"

      Case "GET"
      request = Environ("QUERY_STRING")

      Case "POST"
      length = Val(Environ("CONTENT_LENGTH"))
      Open cons For Input As #1
      request = Space( length )
      Get #1,,request
      Close #1

      Case Else
      Print "Content-type: text/html"
      Print "<html><body>Invalid Request</body></html>"

      End Select

      '' send content

      Print "Content-type: text/html"
      print "<html><body>"
      Print "request:<br>"
      Print "<pre>"
      Print request
      Print "</pre>"
      Print "</body></html>"

    • Show all 7 messages in this topic