How to create an user defined page?

In your example.php file add this line at the top, this will enable all wordpress functions such as $wpdb, get_header(); etc.

<?php require_once('LINK-TO-DIRECTORY/wp-blog-header.php'); ?>

Recommended reading – Codex – Integrating WordPress with Your Website