A pinhole camera is simply a box with a tiny hole in one side and some film or photographic paper on the opposite size. If the box is otherwise "light-tight," the light coming through the pinhole will form a real image on the film. The scientific principle behind this is very simple.
If you were to shine a flashlight in a dark room, through a tiny hole in a wide piece of cardboard, the light would form a dot on the opposite wall. If you moved the flashlight, the light dot would also move -- light beams from the flashlight move through the hole in a straight line.
In a larger visual scene, every particular visible point acts like this flashlight. Light reflects off each point of an object and travels out in all directions. A small pinhole lets in a narrow beam from each point in a scene. The beams travel in a straight line, so light beams from the bottom of the scene hit the top of the piece of film, and vice-versa. In this way, an upside down image of the scene forms on the opposite side of the box. Since the hole is so small, you need a fairly long exposure time to let enough light in.
There are a number of ways to build this sort of camera -- some enthusiasts have even used old refrigerators and cars as light-tight boxes. One of the most popular designs uses an ordinary cylinder oatmeal box, coffee can, or similar container. Its easiest to use a cardboard container with a removable plastic lid.