Self-flagellation is forbidden (Haram) in Islam. Great Shia scholars such as grand Ayatullah Khamenei who is the leader of Islamic Republic of Iran and Ayatullah Sistani, the Shia Leader in Iraq, have prohibited any self-mutilation such as self-flagellation with knives or chains (Tatbir) and even walking on fire. You can see their Fatwas (religious opinions) on tatbir.org