These two lines should be combine based on your requirement
else if (temp2 == 1)
{
}
else if (temp3 == 1)
{
}
To
else if (temp2 == 1 && temp3 == 1)
{
}
This table might help you visualize it better
temp2 temp3 Action
0 0 User Name is Not Recognized
0 1 User Name is Not Recognized
1 0 User Name is Not Recognized
1 1 user can create a username and password
Then you can consolidate the code to something like
else if (temp2 == 0 || temp3 == 0)
{
ScriptManager.....
}