...

View Full Version : login trouble



casto
04-21-2012, 12:50 AM
Hello I am working on my login.aspx page and I am having trouble validating users. I am not getting any errors but the code is always evaluating to
Else
errormessage.Text = "Your email or password is wrong"
End If
eventhough the email and passwords are correct. I also dont know if this is right but i am using the
Membership.ValidateUser(email.Text, password.Text) but using it on a database that i created.






Protected Sub loginbutton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles loginbutton.Click
myconnection = New SqlConnection("Server=localhost\SQLEXPRESS;Database=VoteNow;" &
"Integrated Security=True")
readata = "(SELECT email,password FROM table2 Where email='@email' and password='@password')"
mycommand = New SqlCommand(readata, myconnection)
mycommand.Parameters.AddWithValue("@email", email.Text)
mycommand.Parameters.AddWithValue("@password", password.Text)
myconnection.Open()

If Membership.ValidateUser(email.Text, password.Text) Then
Response.Redirect("~/Account/myaccount.aspx")
myreader = mycommand.ExecuteReader(CommandBehavior.CloseConnection)
Else
errormessage.Text = "Your email or password is wrong"
End If
End Sub
End Class



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum