
- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to process a simple form data using Python CGI script?
suppose there is an HTML file as below −
<form action="getData.py" method="post"> FirstName: <input type="text" name="first_name"> LastName: <input type="text" name="last_name"> <input type="submit" value="go"> </form>
after submitting this form it should go to a python page named getData.py, where you should fetch the data from this HTML page and show. then below is the code for python CGI
#!C:\Python27\python.exe # Import modules for CGI handling import cgi, cgitb # Create instance of FieldStorage form = cgi.FieldStorage() # Get data from fields first_name = form.getvalue('first_name') last_name = form.getvalue('last_name') print("Content-type:text/html") print print("") print("") print("Hello - Second CGI Program") print("") print("") print(" Hello %s %s " % (first_name, last_name)) print("") print("")
- Related Questions & Answers
- How to pass a list Data to Python CGI script?
- How can I access session data using Python CGI script?
- How to pass Checkbox Data to Python CGI script?
- How to redirect a URL using Python CGI script?
- How to send email using Python CGI script?
- How to pass Radio Button Data to Python CGI script?
- How to pass Text Area Data to Python CGI script?
- How to call a python cgi script from another script?
- How to pass variable in one Python CGI script to other Python CGI script?
- How to return JSON object using Python CGI script?
- How to finish a Python CGI script gracefully?
- How to pass Drop Down Box Data to Python CGI script?
- How to upload multiple files via single form field via Python CGI script?
- Simple registration form using Python Tkinter
- How to secure my Python CGI script?
Advertisements