adsense


Saturday, 28 November 2015

C++ LANGUAGE PASSING CHECKBOX DATA TO CGI PROGRAM

COMPUTER LANGUAGES HTML,C,C++.JAVA,.NET AND MULTIMEDIA basics and programs click home button



C++ LANGUAGE PASSING CHECKBOX DATA TO CGI PROGRAM





Passing Checkbox Data to CGI Program 


Checkboxes are used when more than one option is required to be selected. 
Here is example HTML code for a form with two checkboxes: 
<form action="/cgi-bin/cpp_checkbox.cgi"  
         method="POST"  
         target="_blank"> 
<input type="checkbox" name="maths" value="on" /> Maths 
<input type="checkbox" name="physics" value="on" /> Physics 
<input type="submit" value="Select Subject" /> 
</form> 
The result of this code is the following form: 

 Maths 

 Physics 

 Select Subject

Below is C++ program, which will generate cpp_checkbox.cgi script to 
handle input given by web browser through checkbox button. 
#include <iostream> 
#include <vector>   
#include <string>   
#include <stdio.h>   
#include <stdlib.h>  
 
#include <cgicc/CgiDefs.h>  
#include <cgicc/Cgicc.h>  
#include <cgicc/HTTPHTMLHeader.h>  
#include <cgicc/HTMLClasses.h>  
 
using namespace std; 
using namespace cgicc; 
 
int main () 
{ 
   Cgicc formData; 
   bool maths_flag, physics_flag; 
 
   cout << "Content-type:text/html\r\n\r\n"; 
   cout << "<html>\n"; 
   cout << "<head>\n"; 
   cout << "<title>Checkbox Data to CGI</title>\n"; 
   cout << "</head>\n"; 
   cout << "<body>\n"; 
 
   maths_flag = formData.queryCheckbox("maths"); 
   if( maths_flag ) {   
      cout << "Maths Flag: ON " << endl;   
   }else{ 
      cout << "Maths Flag: OFF " << endl;   
   } 
   cout << "<br/>\n"; 
 
   physics_flag = formData.queryCheckbox("physics"); 
   if( physics_flag ) {   
      cout << "Physics Flag: ON " << endl;   
   }else{ 
      cout << "Physics Flag: OFF " << endl;   
   } 
   cout << "<br/>\n"; 
   cout << "</body>\n"; 
   cout << "</html>\n"; 
    
   return 0; 
} 


No comments: