# Form not inserting data into database

**URL:** <https://www.ruby-forum.com/t/form-not-inserting-data-into-database/97296>\
**Category:** Rails\
**Created:** [July 6, 2006, 6:17am UTC](https://www.ruby-forum.com/t/form-not-inserting-data-into-database/97296 "2006-07-06T06:17:04Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![davidstokar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/4da419/32.png) [@davidstokar](https://www.ruby-forum.com/u/davidstokar)\
**Post date:** [July 6, 2006, 6:17am UTC](https://www.ruby-forum.com/t/form-not-inserting-data-into-database/97296/1 "2006-07-06T06:17:04Z")

</div>

I have a form to register a user. The issue I am having is the fact that  
it only populates login, hashed\_password and created\_at fields.

DB table:  
create table users (  
id int not null auto\_increment,  
login varchar(100) default null,  
hashed\_password char(40) default null,  
email varchar(255) default null,  
salt varchar(255) default null,  
address varchar(255) null,  
city varchar(255) not null,  
state varchar(255) not null,  
country varchar(255) not null,  
phone varchar(255) not null,  
website varchar(255) not null,  
created\_at datetime null,  
primary key (id)  
);

users\_controller:

# Add a new user to the database.

def register\_user  
if request.get?  
@user = User.new  
else  
@user = User.new(params[:user])  
if @user.save  
flash[:notice] = “User #{@user.login} created”  
#redirect\_to :action =\> ‘//login/login’  
redirect\_to :controller=\>‘adverts’, :action=\>‘list’#, :id =\>  
@user.id  
end  
end  
end

register\_user.rhtml:

# Please Sign Up
The More information you provide the easier it will be for people to find you or your company. \<%= start\_form\_tag :action =\> 'register\_user' %\> \<%= render :partial =\> 'form' %\> \<%= submit\_tag "Register" %\> \<%= end\_form\_tag %\>

\_form.rhtml:

\<%= error\_messages\_for ‘user’ %\>

Please help

| User name or company name: | \<%= text\_field("user", "login") %\> | |
| Password: | \<%= text\_field("user", "password") %\> | |
| Email: | \<%= text\_field("user", "email") %\> | |
| Address: | \<%= text\_field("user", "address") %\> | |
| City: | \<%= text\_field("user", "city") %\> | |
| State: | \<%= text\_field("user", "state") %\> | |

---

<div class="post-metadata">

**Author:** ![davidstokar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/4da419/32.png) [@davidstokar](https://www.ruby-forum.com/u/davidstokar)\
**Post date:** [July 6, 2006, 3:13pm UTC](https://www.ruby-forum.com/t/form-not-inserting-data-into-database/97296/2 "2006-07-06T15:13:40Z")

</div>

Hi David,

I think the problem is your password field in your form is not matched  
with the field in the database, you should change hashed\_password to  
‘password’.

Hope it helpful.

Socheat

David S. wrote:

> I have a form to register a user. The issue I am having is the fact that  
> it only populates login, hashed\_password and created\_at fields.
