jps services
  • Home Page
  • GIS Training Courses
    • QGIS Training Courses
    • ArcGIS Training Courses
    • MapInfo Pro Training Courses >
      • MapBasic Training Course
  • About
  • Blog

Processing GIS Form Data with PHP: A Beginner's Guide

21/9/2023

0 Comments

 
Geographic Information Systems (GIS) play a crucial role in various fields such as urban planning, environmental management, and location-based services. One common task in GIS is collecting and processing user input through web forms. In this beginner's guide, we will explore how to process form data with PHP, a server-side scripting language widely used for web development.
Understanding the Basics

Before we dive into the code, let's clarify a few fundamental concepts:

HTML Forms
HTML forms are a way for users to input data on a webpage. They consist of various input elements like text fields, checkboxes, radio buttons, and submit buttons. Users fill out these forms, and when they submit the data, it is sent to a server for processing.

PHP
PHP is a server-side scripting language that can handle form data, process it, and interact with databases. It is often used in conjunction with HTML to create dynamic web applications.

POST and GET Methods
HTML forms can use two primary methods to send data to the server: POST and GET. In this guide, we'll focus on the POST method, which is more secure and appropriate for handling sensitive information like user passwords.

Setting Up the HTML Form

Let's start by creating a simple HTML form that collects geographic data. For example, we'll create a form to collect a location name and coordinates (latitude and longitude):
Picture
In this code, we have created a simple HTML form with fields for name, latitude, and longitude. The action attribute specifies the PHP script that will process the data (in this case, `process_data.php`), and we've set the method attribute to "post" to use the POST method.

Processing Form Data with PHP

Now, let's create the PHP script `process_data.php` to handle the form data:
Picture
​In this PHP script, we first check if the request method is POST, which ensures that the form data is being submitted. We then use the `$_POST` superglobal to retrieve the values entered in the form fields and store them in variables.

Now, you can use this collected data for various GIS-related tasks, such as storing it in a database, performing spatial analysis, or displaying it on a map. In the following images we show the name, latitude and longitude fields completed.  Once the Submit button is pressed the process_data.php code displays the results in a new page.  Of course in a real application we would save this information to a relational database rather than just displaying the results.
Picture
​Processing form data with PHP is an essential skill for GIS beginners, as it allows you to gather user input and manipulate geographic information effectively.
Picture
​​
With this guide, you should have a solid foundation for creating HTML forms, collecting data, and using PHP to process and work with that data in your GIS applications. As you continue to explore GIS development, you'll find countless opportunities to leverage these skills to build powerful and interactive web-based geographic applications. Happy coding!
0 Comments

Your comment will be posted after it is approved.


Leave a Reply.

    Author

    Joe Short BSc has been involved with various mapping solutions for over twenty years.  If you are considering implementing a GIS  or have ArcGIS Pro, MapInfo Pro or QGIS training requirements, jps services would be happy to be of assistance to your organisation. 

    Archives

    May 2025
    March 2025
    March 2024
    October 2023
    September 2023
    August 2023
    March 2023
    April 2020
    March 2020
    October 2019
    September 2019
    August 2019
    July 2019
    March 2019
    November 2018
    October 2018
    August 2018
    July 2018
    November 2017
    October 2017
    September 2017
    July 2017
    February 2017
    January 2017
    December 2016
    November 2016
    October 2016
    May 2016
    February 2016
    September 2015
    August 2015
    April 2015
    February 2015
    November 2014
    October 2014
    July 2014
    June 2014
    May 2014
    March 2014
    February 2014
    December 2013
    November 2013
    October 2013
    September 2013
    August 2013
    June 2013
    May 2013
    April 2013
    February 2013
    December 2012
    October 2012
    September 2012
    August 2012
    July 2012

    Categories

    All
    Arc Gis
    Arcview
    Autodesk
    Cad
    Gis Training
    Local Government
    Mapbasic
    Mapinfo
    Quantum Gis
    Relational Databases
    Saga Gis

    RSS Feed