Creating CGI Script

We’ll use the CGI directory provided by XAMPP “C:\xampp\cgi-bin” for storing the CGI script.

Now create a new file with a .cgi extension and paste the following code into this new file.

#!"C:\xampp\perl\bin\perl.exe"
print "Content-Type: text/html\n\n";
print "<h1>Geeks For Geeks</h1>";
print "<p>This is a cgi-script</p>";

How to create a simple CGI script?

In this article, we will explore how to create a simple CGI (Common Gateway Interface) script on a Windows machine but before that, we need some basic ideas about these technologies ( CGI Script, HTTP, Web Server ).
CGI Script: A CGI script is a program that runs on a web server and generates dynamic web content. It’s often used for processing web forms, interactive web applications, and server-side tasks.
HTTP: Hypertext Transfer Protocol is the foundation of data communication on the World Wide Web. It defines how messages are formatted and transmitted.
Web Server: A web server is software that serves web content to users, listening for incoming requests and responding by delivering web pages or running CGI scripts.

Prerequisites: Please ensure that XAMPP is installed on your machine before continuing. If not then please refer to XAMPP installation in Windows.

Similar Reads

Creating CGI Script

We’ll use the CGI directory provided by XAMPP “C:\xampp\cgi-bin” for storing the CGI script....

Running and Testing the CGI Script

In this section, we will run and test our CGI Script on web server using XAMPP....

Contact Us