Reputation:
y'all, I'm making a simple sign-up/registration form and then submitting it to my (localhost) database. The main problem that I am having is that I can't get the data is actually get passed to my database. I am using Laravel 4 to handle the backend, but I am fairly new to it, so I'm sure there is an obvious mistake that I am making, but I can't seem to see it.
Here is the form that I have created using Twitter Bootstrap. There is nothing wrong with the action = "/adding_to_table" route call.
<!DOCTYPE html>
<html>
<head>
<link class="cssdeck" rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/2.3.1/css/bootstrap.min.css">
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/2.3.1/css/bootstrap-responsive.min.css" class="cssdeck">
</head>
<body>
<div class="" id="loginModal">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<!--<h3>Have an Account?</h3>-->
</div>
<div class="modal-body">
<div class="well">
<div id="myTabContent" class="tab-content">
<div class="tab-pane active in" id="login">
<form method="" action='/adding_to_table' class="form-horizontal">
<fieldset>
<div id="legend">
<legend class="">Create Your Account</legend>
</div>
<div class="control-group">
<!-- Username -->
<label class="control-label" for="firstname">First Name</label>
<div class="controls">
<input type="text" id="first_name" name="firstname" placeholder="" class="input-xlarge">
</div>
</div>
<div class="control-group">
<!-- Username -->
<label class="control-label" for="lastname">Last Name</label>
<div class="controls">
<input type="text" id="last_name" name="lastname" placeholder="" class="input-xlarge">
</div>
</div>
<div class="control-group">
<!-- Username -->
<label class="control-label" for="email">E-mail</label>
<div class="controls">
<input type="text" id="e_mail" name="email" placeholder="" class="input-xlarge">
</div>
</div>
<div class="control-group">
<!-- Username -->
<label class="control-label" for="username">Username</label>
<div class="controls">
<input type="text" id="username" name="username" placeholder="" class="input-xlarge">
</div>
</div>
<div class="control-group">
<!-- Password-->
<label class="control-label" for="password">Password</label>
<div class="controls">
<input type="password" id="password" name="password" placeholder="" class="input-xlarge">
</div>
</div>
<div class="control-group">
<!-- Button -->
<div class="controls">
<button class="btn btn-primary">Submit</button>
</div>
</div>
</fieldset>
</form>
</div>
</div>
</div>
</div>
<script class="cssdeck" src="//cdnjs.cloudflare.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script class="cssdeck" src="//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/2.3.1/js/bootstrap.min.js"></script>
</body>
<html>
Now, here is the file that is supposed to be taking care of putting the data in the database:
DB::table('user_info')->insert(
array("First_name" => Input::get('first_name'),
"Last_name" => Input::get("last_name"),
"E-mail" => Input::get("e_mail"),
"Username" => Input::get("username"),
"Password" => Input::get("password")
)
);
echo "Successfully entered user information into data table";
Whenever I fill out my form and hit submit, I get the "Whoops, looks like something went wrong" error from Laravel and I'm not quite sure why. Any help that y'all can give would be much appreciated!
Upvotes: 0
Views: 83
Reputation: 116
You are targeting the id's of your form elements instead of the names. Try using the name
attribute:
DB::table('user_info')->insert(
array("First_name" => Input::get('firstname'),
"Last_name" => Input::get("lastname"),
"E-mail" => Input::get("email"),
"Username" => Input::get("username"),
"Password" => Input::get("password")
)
);
if you use method="POST"
then try:
DB::table('user_info')->insert(
array("First_name" => Input::post('firstname'),
"Last_name" => Input::post("lastname"),
"E-mail" => Input::post("email"),
"Username" => Input::post("username"),
"Password" => Input::post("password")
)
);
Upvotes: 1