I will use pseudo-code to explain .
Use a select query with a WHERE that gonna select only value/values that is/are equal to the value/values of the input type .
You will have to store the values in variables , one variable for the input type and one variable to store the value for the select query.
Before that don't forget to store variables because if you do a search it will read the value but not gonna store it and the second reason is it's gonna help you for the if and else if .
Also i will recommend you to see POST method and REQUEST method and logic operators ( ex: && , || , etc ... )
You should use a if and a else if .
The if could be:
if variable1 = variable 2
echo "Data already exist" ;
end of the if
the else if could be :
Insert query
end of the else
You should echo the value that you get from the select query just to be sure for your test.