Ich habe eine Tasche für meinen Bruder.
Ich habe meinem Bruder eine Tasche.
The first sentence with Akkusativ preposition while the second one with Dativ. Which one is correct? Or may be both?
You present an interesting pair of sample sentences. Indeed, from the viewpoint of pure grammar, both sentences are "correct", but the second
*Ich habe meinem Bruder eine Tasche
is so unusual that almost everybody will tell you it is wrong.
I, however, claim that it is grammatically acceptable. Why? There are both in dialects of German and in German colloquial language various expressions that use exactly your syntactical construct, although with other topics:
Hast du mir mal 'ne Zigarette?
Do you have a cigarette for me?
Hier, ich hab' dir ein Geschenk.
Here, I have a present for you.
But, as I said, this is very specifically colloquial language. These things do not work that way in (orderly) written language. So, as learner of German: just do not use it actively. But do not be puzzled when you hear it in some informal conversation.
I suppose that you are confusing two concepts:
Let us consider the following two sentences, which differ only in the verb:
- Ich kaufe eine Tasche. → I buy a bag.
- Ich habe eine Tasche. → I have a bag.
Now, we want to express that the bag is for your brother. In both cases, you can do this using the accusative preposition für:
- Ich kaufe eine Tasche für meinen Bruder. → I buy a bag for my brother.
- Ich habe eine Tasche für meinen Bruder. → I have a bag for my brother.
For the verb kaufen there is another possibility: The act of buying can have a recepient, i.e., your brother; and this can be expressed in terms of a dative object. However, this does not work with haben; the act of having something does not have a receipient.
- Ich kaufe meinem Bruder eine Tasche. → I buy my brother a bag.
Ich habe meinem Bruder eine Tasche. → I have my brother a bag.