Check your version

This tutorial covers a topic in Drupal 7 which may or may not be the version you're using. We're keeping this tutorial online as a courtesy to users of Drupal 7, but we consider it archived.

Last updated June 7, 2017

Make SQL queries in Drupal, make HTTP requests to external websites, and use this data to validate a form.

Objectives and Prerequisites

You will need the following knowledge and skills. If you need a review, check out the Resources section at the bottom of this page.

  1. Understand how to check for the existence of a property on a node.
  2. Create a validation hook for a form.
  3. Use an external API to access data to use for validation.


Create a function to check for the existence of a matching node within Drupal using the Drupal database abstraction layer. Return a boolean for whether it exists or not. If it does, notify the user that the node already exists.

Create a function which makes an API request to search for a movie in the The Movie DB API with a matching title. If it does not exist, notify the user the movie does not exist in the external database. If it does exist, return the data object.


  • All database transactions happen via an abstraction layer.
  • Making requests to external URLs is simple in Drupal 7.


Creative Commons License

Drupal Training Resources by Damian Robinson are licensed under a Creative Commons Attribution-ShareAlike 4.0 International License. Based on a work at