I strongly advise against trying to bootstrap drupal from an external script.
A much simpler solution for you would be to create a page, and put all the processing in the theme file for that page. If the page you created has nid X, create page--X.tpl.php and put whatever you want there.
Remember that this method is "dirty" and in the long run when you are more comfortable with writing modules you should not put this logic in the theme files. But for now, I think this is your best bet.