I have a Usetable contains username and password fields and inserted one value to that table
username:admin password:text In view file contains text boxes for username and password and a login button as follows.
<%= form_tag(:action =>"login", :method => "post", :id=>"frm") do %>
User Name:<%= text_field_tag(:username) %>
Password:<%= text_field_tag(:password) %>
<%= button_to("login ", :class=>"btn") %>
<% end %>
if the enterd username and password is same as the data present in the usertable redirct to home page other wise login is not succesful
What i want is
while clicking on the login button pass the username text and password text to controller
execute a mysql query like select * from usertable where uername=** and password=**
I dont know how to write mysql query inside controller method.How it is possible? my controller class looks like
class UsersController < ApplicationController
def home
@username=params[:username]
@password=params[:password]
# here i have to write that query.#
render :action => :home
end
end
Iam using rails 3