how to make forms

 
Post new topic   Reply to topic    Aprelium Forum Index -> Web Design
View previous topic :: View next topic  
Author Message
mattp222
-


Joined: 05 Oct 2009
Posts: 4

PostPosted: Mon Oct 05, 2009 4:08 pm    Post subject: how to make forms Reply with quote

can any of you suggest the best method for making a from with the cgi-bin for abyss?
Back to top View user's profile Send private message
JackWebb
-


Joined: 25 Sep 2009
Posts: 4

PostPosted: Wed Dec 16, 2009 4:23 am    Post subject: Reply with quote

CGI is a method, not something you use to make forms. You can make forms using HTML. The HTML form calls the the executable code using CGI. The executable code can be code from a scripting language like PERL, PHP or a native executable like .EXE in Windows.

CgiTest.html
Code:
<html>
<body>
<h1>POST & GET CGI Demo</h1>

<B>GET Example #1</b><br>
<a href="/cgi-bin/cgitest.exe?name=John&phone=555-1234">
PureBASIC cgi test
</a>
<br>
<br>

<B>GET Example #2</b><br>
<form method="get" action="/cgi-bin/cgitest.exe">
<input type="text" name="name" value="Paul">
<input type="text" name="phone" value="555-1234">
<input type="submit" value="Submit">
</form>
<br>
<br>

<B>POST Example #1</b><br>
<form method="post" action="/cgi-bin/cgitest.exe">
<input type="text" name="name" value="George">
<input type="text" name="phone" value="555-1234">
<input type="submit" value="Submit">
</form>
<br>
<br>

<B>POST Example #2</b><br>
<form method="post" ACTION="/cgi-bin/cgitest.exe">
<P>Name :<input type="text" name="name" size=35>
<P>Phone:<input type="text" name="phone" size=35>
<P><input type="submit" value="Submit">
</form>
<br>
<br>

<center>
<h5>This page has been viewed <!-- #exec cgi="/cgi-bin/hitcounter.exe" --> times<h5>
</center>

</body>
</html>


CgiTest.exe
Code:
EnableExplicit

;- CGI Example. A simple POST & GET Demo in PureBASIC
;  JackWebb 2009
;  PureBASIC 4.40
;  Abyss WebServer 2.6X2

Define Param$
Define Name$
Define Phone$
Define Date$
Define Time$
Define FreeFile
Define Method$

If OpenConsole()
 Method$ = GetEnvironmentVariable("REQUEST_METHOD") ; Get Method, POST or GET

  If Method$ = "POST"
    Param$ = "?" + Input() ; POST goes to STDIN
  Else
    Param$ = "?" + GetEnvironmentVariable("QUERY_STRING") ; GET goes to Environment
  EndIf

  Name$  = GetURLPart(Param$, "name")
  phone$ = GetURLPart(Param$, "phone")

  PrintN("content-type: text/html") ; Create header
  PrintN("")                        ; this is part of the header

  PrintN("<html>")                  ; Build the page
  PrintN("<head>")
  PrintN("<title>PureBASIC CGI</title>")
  PrintN("</head>")

  PrintN("<body>")
  PrintN("<h1>POST & GET Demo</h1>")

  PrintN("<pre>")
  PrintN("Name  = " + Name$)
  PrintN("Phone = " + Phone$)
  PrintN("</pre>")

  PrintN("")
  PrintN("REQUEST_METHOD  = " + Method$) ; GET or POST
  PrintN("</body>")
  PrintN("</html>")

  CloseConsole()

  Date$ = FormatDate("%mm/%dd/%yyyy", Date()) ; Prepare time information for log file
  Time$ = FormatDate("%hh:%ii:%ss", Date())

  FreeFile = OpenFile(#PB_Any, "cgitest.txt") ; Print results to file for inspection
  If FreeFile
    FileSeek(FreeFile, Lof(FreeFile))
    WriteStringN(FreeFile, "cgitest was run on " + Date$ + " at " + Time$ + " " + Method$ + " " + Param$)
    CloseFile(FreeFile)
  EndIf

EndIf
End


HitCounter.exe
Code:
EnableExplicit

;- CGI Example. A simple page HitCounter in PureBASIC
;  JackWebb 2009
;  PureBasic 4.40
;  Abyss WebServer 2.6X2

Define Hits
Define FreeFile

FreeFile = OpenFile(#PB_Any, "hitcounter.txt")
If FreeFile
  Hits = ReadLong(FreeFile) + 1
  FileSeek(FreeFile, 0)
  WriteLong(FreeFile, Hits)
  CloseFile(FreeFile)
EndIf

If OpenConsole()
  PrintN("content-type: text/html") ;- Create the header
  PrintN("")                        ;  This has to be here
  Print(Str(Hits))                  ;  Print number to STDOUT
  CloseConsole()
EndIf
End
Back to top View user's profile Send private message
Bastawy
-


Joined: 18 Jan 2009
Posts: 9

PostPosted: Sun Dec 27, 2009 2:06 pm    Post subject: Reply with quote

Thanks for this helpful post i was really looking how to make a web form
_________________
baltimore vw | maryland vw | maryland mazda
Back to top View user's profile Send private message
bprsk8r4272
-


Joined: 07 Mar 2006
Posts: 124
Location: Rochester, NY

PostPosted: Thu Jan 28, 2010 12:32 am    Post subject: Reply with quote

http://bebosoft.com/products/formstogo/overview with this you can create many types of forms
_________________
Back to top View user's profile Send private message Send e-mail Visit poster's website AIM Address MSN Messenger
markspenser
-


Joined: 23 Jul 2009
Posts: 14

PostPosted: Wed Apr 07, 2010 11:39 am    Post subject: i am not getting your clearly Reply with quote

please elaborate your question.
Back to top View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Aprelium Forum Index -> Web Design All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB phpBB Group