Detect if a plugin was included in a certain page

If I understand correctly you want to include a php file that validates the form input, but only when you need to actually validate something?

In this case, you don’t need to check if the contact form exists on some page – you just need to check if the form data has been posted. All you need to do is add a hidden field to the form, with a unique identifier:

 <input type="hidden" name="my_plugin_contact_form" value="true"/>

This is just to enable us to know when data from your plug-in form has been posted:

<?php if(!empty($_REQUEST['my_plugin_contact_form'])) : ?>
    //perform validation
<?php endif; ?>

I’ve noticed that you want to include the validation check inside a page template. I would recommend instead that you wrap your validation inside a function and hook it onto something like init.

A final note: this is not a replacement for using nonces. The above check is only so we know that validation is required – you should still check:

  1. Nonces: did the data come from our form?
  2. Permissions: does the user have permission to send this data

No.2 is probably less relevant here.