In order for a Mezuzah to be Kosher, it has to be well affixed. Well affixed means that it is not easy to remove, and that it doesn't swing back and forth. We see this from the blessing that we recite when affixing a Mezuzah. It ends with the words, "who has commanded us to affix (Likvoa) the Mezuzah". The Hebrew word 'likvoa' means to affix something very well.
For example if you put your mezuzah up with a couple pieces of scotch tape it would not be Kosher. This is because anyone could walk by and pull it down with very little effort. That is not called being well affixed. If you put your Mezuzah up using only one nail on the top it is also not Kosher even though it may be difficult to remove. This is because it will be able to swing back and forth.
Based on this we can see that anything which affixes a Mezuzah well to the doorpost is Kosher. Nails or screws will obviously qualify. Glue or other strong adhesive also is fine. there are alos several brands of double sided mounting tape which are very strong and perfectly Kosher for affixing your Mezuzah. I personally recommend the mounting tapes made by 3-M. They make one type with a green and white backing which is great for indoors Mezuzahs. They have another type with a red backing which is weather proof and is excellent for indoor or outdoor use.
If you are going to be using mounting tape to affix your Mezuzah, just be sure to clean the area where you are going to put the Mezuzah. Let it dry thoroughly before sticking it on. Then when you put it up, press very firmly. It should stay in place for many years.
I have seen some people who used Velcro to put up their Mezuzah. They do this because one is supposed to take down the Mezuzah every few years to have it checked. They say that this makes it easier to take them down for checking and replace them when the time comes. The big problem with this is that Velcro is made for attaching things temporarily. That means that by definition, something which is attached with Velcro is not affixed. Based on this most Rabbis rule that you are not allowed to put your Mezuzah up with Velcro.
In short, anything which attaches a Mezuzah very well to the door in a permanent fashion is Kosher.