| View previous topic :: View next topic | 
	
	
		| Author | Message | 
	
		| mattp222 -
 
 
 Joined: 05 Oct 2009
 Posts: 4
 
 
 | 
			
				|  Posted: Mon Oct 05, 2009 4:08 pm    Post subject: how to make forms |   |  
				| 
 |  
				| can any of you suggest the best method for making a from with the cgi-bin for abyss? |  | 
	
		| Back to top |     | 
	
		|  | 
	
		| JackWebb -
 
 
 Joined: 25 Sep 2009
 Posts: 4
 
 
 | 
			
				|  Posted: Wed Dec 16, 2009 4:23 am    Post subject: |   |  
				| 
 |  
				| 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 |     | 
	
		|  | 
	
		| Bastawy -
 
 
 Joined: 18 Jan 2009
 Posts: 9
 
 
 |  | 
	
		| Back to top |     | 
	
		|  | 
	
		| bprsk8r4272 -
 
 
 Joined: 07 Mar 2006
 Posts: 124
 Location: Rochester, NY
 
 |  | 
	
		| Back to top |             | 
	
		|  | 
	
		| markspenser -
 
 
 Joined: 23 Jul 2009
 Posts: 14
 
 
 | 
			
				|  Posted: Wed Apr 07, 2010 11:39 am    Post subject: i am not getting your clearly |   |  
				| 
 |  
				| please elaborate your question. |  | 
	
		| Back to top |     | 
	
		|  | 
	
		|  |