Question: is if it were grammatically correct?
Answer: Those are both grammatical, but mean very different things. 'If I were' is in the subjective mood, 'if I was' is in the indicitive mood. 'If I were' is correct in the vast majority of cases. A verb is in the subjunctive mood when it expresses a condition which is doubtful or not factual.