i want to make two inserts in same table.
The table is based on this fields (locale, project_id(foreign key), title, caption).
And the controller looks like here:
public function storeTranslation(Request $request)
{
$projecttranslation = new ProjectTranslation();
$projecttranslation->locale = $request->input("locale");
$projecttranslation->project_id = $request->input("project");
$projecttranslation->title = $request->input("title");
$projecttranslation->caption = $request->input("caption");
$projecttranslation->save();
}
The form for the moment looks like here:
<div id="form2" style="display:none;" class="col-md-6">
<div class="col-md-">
<h3>Crear nueva traduccion</h3>
<form enctype="multipart/form-data" id="myFormTraduccion" name="myFormTraduccion"><!--FIRST FORM TO TRANSLATE -->
<input type="hidden" name="_token" value="{{ Session::token() }}">
<div class="form-group">
<label name="Language">Language:</label>
<input type="text" id="locale" name="locale" value="en" class="form-control form-control-sm">
<label name="Project">Project id:</label>
<input type="number" id="project" name="project" class="form-control form-control-sm">
<label name="Title">Title:</label>
<input type="text" id="title" name="title" class="form-control form-control-sm">
<label name="Caption">Caption:</label>
<input type="text" id="caption" name="caption" class="form-control form-control-sm"><br>
<input type="submit" value="Crear Traduccion" id="createtranslatesubmit" class="btn btn-danger btn-md">
<br><br><br>
</div>
</form> <!-- FIRST FORM TO TRANSLATE END HERE -->
<form enctype="multipart/form-data" id="myFormTraduccion2" name="myFormTraduccion2"> <!--SECOND FORM TO TRANSLATE -->
<input type="hidden" name="_token" value="{{ Session::token() }}">
<div class="form-group">
<label name="title">Language:</label>
<input type="text" id="locale" name="locale" value="es" disabled class="form-control form-control-sm">
<label name="order">Project id:</label>
<input type="number" id="project" name="project" class="form-control form-control-sm">
<label name="public">Title:</label>
<input type="text" id="title" name="title" class="form-control form-control-sm">
<label name="caption">Caption:</label>
<input type="text" id="caption" name="caption" class="form-control form-control-sm"><br>
<input type="submit" value="Crear Traduccion" id="createtranslatesubmit2" class="btn btn-danger btn-md">
<br><br><br>
</div>
</form> <!--SECOND FORM TO TRANSLATE END HERE -->
</div>
</div>
And the ajax look like this:
$("#createtranslatesubmit").click(function(){
$("#myFormTraduccion").submit();
});
$("#myFormTraduccion").submit(function(e){
e.preventDefault();
$.ajax({
url:'/admin/projects/postUploadTranslation',
type:'POST',
data:$('#myFormTraduccion').serializeArray(),
success: function(){
$("#form2").fadeOut(1000);
$("#form3").fadeIn(2000);
}
});
});
This create only with the first form, the first translation.
I think i should change the view code to this (Two same inputs for each field of database):
<div id="form2" style="display:none;" class="col-md-6">
<div class="col-md-">
<h3>Crear nueva traduccion</h3>
<form enctype="multipart/form-data" id="myFormTraduccion" name="myFormTraduccion"><!--FIRST FORM TO TRANSLATE -->
<input type="hidden" name="_token" value="{{ Session::token() }}">
<div class="form-group">
<label name="Language">Language:</label>
<input type="text" id="locale" name="locale" value="en" class="form-control form-control-sm">
<label name="Project">Project id:</label>
<input type="number" id="project" name="project" class="form-control form-control-sm">
<label name="Title">Title:</label>
<input type="text" id="title" name="title" class="form-control form-control-sm">
<label name="Caption">Caption:</label>
<input type="text" id="caption" name="caption" class="form-control form-control-sm">
<label name="title">Language:</label>
<input type="text" id="locale" name="locale" value="es" class="form-control form-control-sm">
<label name="order">Project id:</label>
<input type="number" id="project" name="project" class="form-control form-control-sm">
<label name="public">Title:</label>
<input type="text" id="title" name="title" class="form-control form-control-sm">
<label name="caption">Caption:</label>
<input type="text" id="caption" name="caption" class="form-control form-control-sm"><br>
<input type="submit" value="Crear Traduccion" id="createtranslatesubmit" class="btn btn-danger btn-md">
<br><br><br>
</div>
</form> <!-- FIRST FORM TO TRANSLATE END HERE -->
</div>
</div>
That's correct? The problem to "store" the data, i think will be a foreach in controller.
And finally, i don't have any idea, how to pass the data in the ajax, with a formdata maybe?
Thanks a lot, any help will be appreciated!
When you submit a form, you send to the server the data of that specific form. Your approach of using multiple forms doesn't work here, because you want to send all data with only 1 specific form submit.
So you have to only create 1 form and separate the different translations with a numeric reference.
Your HTML (note the -0 and -1 used to separate id and name of each input element) :
<form enctype="multipart/form-data" id="myFormTraduccion" name="myFormTraduccion"><!--FIRST FORM TO TRANSLATE -->
<input type="hidden" name="_token" value="{{ Session::token() }}">
<div class="form-group">
<label name="Language">Language:</label>
<input type="text" id="locale-0" name="locale-0" value="en" class="form-control form-control-sm">
<label name="Project">Project id:</label>
<input type="number" id="project-0" name="project-0" class="form-control form-control-sm">
<label name="Title">Title:</label>
<input type="text" id="title-0" name="title-0" class="form-control form-control-sm">
<label name="Caption">Caption:</label>
<input type="text" id="caption-0" name="caption-0" class="form-control form-control-sm">
<label name="title">Language:</label>
<input type="text" id="locale-1" name="locale-1" value="es" class="form-control form-control-sm">
<label name="order">Project id:</label>
<input type="number" id="project-1" name="project-1" class="form-control form-control-sm">
<label name="public">Title:</label>
<input type="text" id="title-1" name="title-1" class="form-control form-control-sm">
<label name="caption">Caption:</label>
<input type="text" id="caption-1" name="caption-1" class="form-control form-control-sm"><br>
<input type="submit" value="Crear Traduccion" id="createtranslatesubmit" class="btn btn-danger btn-md">
<br><br><br>
</div>
</form>
The controller:
public function storeTranslation(Request $request)
{
$projecttranslation0 = new ProjectTranslation();
$projecttranslation0->locale = $request->input("locale-0");
$projecttranslation0->project_id = $request->input("project-0");
$projecttranslation0->title = $request->input("title-0");
$projecttranslation0->caption = $request->input("caption-0");
$projecttranslation0->save();
$projecttranslation1 = new ProjectTranslation();
$projecttranslation1->locale = $request->input("locale-1");
$projecttranslation1->project_id = $request->input("project-1");
$projecttranslation1->title = $request->input("title-1");
$projecttranslation1->caption = $request->input("caption-1");
$projecttranslation1->save();
}
Of course, it can be easily generalized for N multiple transations and not only 2.
try this out:
<div id="form2" style="display:none;" class="col-md-6">
<div class="col-md-">
<h3>Crear nueva traduccion</h3>
<form enctype="multipart/form-data" id="myFormTraduccion" name="myFormTraduccion"><!--FIRST FORM TO TRANSLATE -->
<input type="hidden" name="_token" value="{{ Session::token() }}">
<div class="form-group">
<label name="Language">Language:</label>
<input type="text" id="locale" name="ProjectTranslation[0][locale]" value="en" class="form-control form-control-sm">
<label name="Project">Project id:</label>
<input type="number" id="project" name="ProjectTranslation[0][project]" class="form-control form-control-sm">
<label name="Title">Title:</label>
<input type="text" id="title" name="ProjectTranslation[0][title]" class="form-control form-control-sm">
<label name="Caption">Caption:</label>
<input type="text" id="caption" name="ProjectTranslation[0][caption]" class="form-control form-control-sm">
<label name="title">Language:</label>
<input type="text" id="locale" name="ProjectTranslation[1][locale]" value="es" class="form-control form-control-sm">
<label name="order">Project id:</label>
<input type="number" id="project" name="ProjectTranslation[1][project]" class="form-control form-control-sm">
<label name="public">Title:</label>
<input type="text" id="title" name="ProjectTranslation[1][title]" class="form-control form-control-sm">
<label name="caption">Caption:</label>
<input type="text" id="caption" name="ProjectTranslation[1][caption]" class="form-control form-control-sm"><br>
<input type="submit" value="Crear Traduccion" id="createtranslatesubmit" class="btn btn-danger btn-md">
<br><br><br>
</div>
</form> <!-- FIRST FORM TO TRANSLATE END HERE -->
</div>
So you will get array of ProjectTranslation at controller side
Now at controller side
public function storeTranslation(Request $request)
{
$form_data = $request->get('ProjectTranslation');
foreach($form_data as $form){
$projecttranslation = ProjectTranslation::create($form);
$projecttranslation->save();
}
}
Related
I want to update the record of the corresponding id that is sent on clicking save button. I tried button tage, input tage and link tage but there is some mistake that I am making, but I don't know where?
This is my form
<form method="POST" action="handle_update.php">
<div class="mb-3">
<label for="exampleInputEmail1" class="form-label">First name</label>
<input type="text" name="fname" value="'.$first_name.'" class="form-control" >
</div>
<div class="mb-3">
<label for="exampleInputPassword1" class="form-label">Last name</label>
<input type="text" name="last_name" value="'.$last_name.'" class="form-control">
</div>
<div class="mb-3">
<label for="exampleInputPassword1" class="form-label">Email</label>
<input type="email" name="email" value="'.$email.'" class="form-control">
</div>
<div class="mb-3">
<label for="exampleInputPassword1" class="form-label">Designation</label>
<input type="text" name="designation" value="'.$designation.'" class="form-control">
</div>
<div class="mb-3">
<label for="exampleInputPassword1" class="form-label">Address</label>
<input type="address" name="address" value="'.$address.'" class="form-control">
</div>
<div class="mb-3">
<label for="exampleInputPassword1" class="form-label">Date of Joining</label>
<input type="date" name="joining_date" value="'.$joining_date.'" class="form-control">
</div>
<a name="update" role = "button" type="submit" href="handle_update.php?ployee_id='.$id2.'">Save</a>
</form>
Add a hidden input field that holds the value you want to submit. Change your <a> to a <button> that can submit your form. Change your code to:
<form method="POST" action="handle_update.php">
<input type="hidden" name="ployee_id" value="' . $id2 . '">
<div class="mb-3">
<label for="exampleInputEmail1" class="form-label">First name</label>
<input type="text" name="fname" value="'.$first_name.'" class="form-control" >
</div>
<div class="mb-3">
<label for="exampleInputPassword1" class="form-label">Last name</label>
<input type="text" name="last_name" value="'.$last_name.'" class="form-control">
</div>
<div class="mb-3">
<label for="exampleInputPassword1" class="form-label">Email</label>
<input type="email" name="email" value="'.$email.'" class="form-control">
</div>
<div class="mb-3">
<label for="exampleInputPassword1" class="form-label">Designation</label>
<input type="text" name="designation" value="'.$designation.'" class="form-control">
</div>
<div class="mb-3">
<label for="exampleInputPassword1" class="form-label">Address</label>
<input type="address" name="address" value="'.$address.'" class="form-control">
</div>
<div class="mb-3">
<label for="exampleInputPassword1" class="form-label">Date of Joining</label>
<input type="date" name="joining_date" value="'.$joining_date.'" class="form-control">
</div>
<button type="submit" name="update">Save</button>
</form>
More on forms: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/form
More on hidden inputs: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/hidden
I am trying to post a form from a HTML file to a live database using laravel api.php route. But it's yielding the following error :
my api.php looks like :
<?PHP
use Illuminate\Http\Request;
use App\Http\Controllers\User\PageController;
Route::middleware('auth:api')->get('/user', function (Request $request) {
return $request->user();
});
Route::post('summitRegistration',[PageController::class,'summitRegistration']);
My HTML code :
<form action="https://www.aspireelearning.com/summitRegistration" method="POST">
<div class="col-12 col-md-6">
<div class="form-group">
<input type="text" class="form-control" name="full_name" id="full_name"
placeholder="Your Full Name">
<input type="text" class="form-control" name="phone" id="phone"
placeholder="Phone Number">
<input type="text" class="form-control" name="profession" id="profession"
placeholder="Profession">
</div>
</div>
<div class="col-12 col-md-6">
<div class="form-group">
<input type="email" class="form-control" name="email" id="email"
placeholder="Email Address" required>
<input type="text" class="form-control" name="organization" id="organization"
placeholder="Organization/Institute">
<select class="form-control country-search" name="country" id="country">
<option value="">Your Country</option>
<option value="">USA</option>
<option value="">UK</option>
</select>
</div>
</div>
<div class="col-12 text-center">
<button type="submit" class="btn btn-danger">
CONFIRM
</button>
</div>
</form>
i have update action and also added #csrf token now i hope you will get your out put .
<form action="https://www.aspireelearning.com/api/summitRegistration" method="POST">
//#csrf
<div class="col-12 col-md-6">
<div class="form-group">
<input type="text" class="form-control" name="full_name" id="full_name"
placeholder="Your Full Name">
<input type="text" class="form-control" name="phone" id="phone"
placeholder="Phone Number">
<input type="text" class="form-control" name="profession" id="profession"
placeholder="Profession">
</div>
</div>
<div class="col-12 col-md-6">
<div class="form-group">
<input type="email" class="form-control" name="email" id="email"
placeholder="Email Address" required>
<input type="text" class="form-control" name="organization" id="organization"
placeholder="Organization/Institute">
<select class="form-control country-search" name="country" id="country">
<option value="">Your Country</option>
<option value="">USA</option>
<option value="">UK</option>
</select>
</div>
</div>
<div class="col-12 text-center">
<button type="submit" class="btn btn-danger">
CONFIRM
</button>
</div>
</form>
You have to add api as prefix https://www.aspireelearning.com/api/summitRegistration
I have a form with dynamic fields. When I add a dynamic field and do a var_dump of that field, I am getting only the first result.
Form:
<div class="form-group halltype">
<label class="col-sm-2 col-sm-2 control-label">HallType</label>
<div class="col-sm-10">
<input type="text" class="form-control" name="title1[]" placeholder="Main Title"><br />
<input type="text" class="form-control" name="title2[]" placeholder="Title 2"><br />
<input type="text" class="form-control" name="seating[]" placeholder="Seating Capacity"><br />
<input type="text" class="form-control" name="floating[]" placeholder="Floating Capacity"><br />
</div>
</div>
<div class="form-group addhalltype">
<label class="col-sm-2 col-sm-2 control-label"></label>
<div class="col-sm-10">
<input type="button" class="btn btn-info" id="">Add Hall Type</button>
</div>
Jquery:
$(".addhalltype").click(function() {
$halltype = '<div class="form-group halltype"><label class="col-sm-2 col-sm-2 control-label">HallType</label><div class="col-sm-10"><input type="text" class="form-control" name="title1[]" placeholder="Main Title"><br /><input type="text" class="form-control" name="title2[]" placeholder="Title 2"><br /><input type="text" class="form-control" name="seating[]" placeholder="Seating Capacity"><br /><input type="text" class="form-control" name="floating[]" placeholder="Floating Capacity"><br /></div></div>';
$($halltype).insertBefore(".addhalltype");
});
and if I do var_dump($_POST['title1']), I get
array(1) {
[0]=>
string(4) "1212"
}
you are printing $_POST['title1'] in var_dump it will show you only value that u inserted for name="title1[]".
Here you are using dynamic array but with different name ie name equal to title1[] title1[] seating[] and floating[].
if you want to get all the post values in one name like title[0],title[1],...title[n] to get the result in this format you have to write your above code with this format.
<input type="text" class="form-control" name="title[]" placeholder="Main Title"><br />
<input type="text" class="form-control" name="title[]" placeholder="Title 2"><br />
<input type="text" class="form-control" name="title[]" placeholder="Seating Capacity"><br />
<input type="text" class="form-control" name="title[]" placeholder="Floating Capacity"><br />
I'm a CS student and I have a DB project due in less than 24hrs! This is really annoying because I just need to forms to access my DB. Anyway, I have this form that works perfectly, while the second form does not work. Instead of posting and directing to the correct URL the second form re-loads the current page with the variables in the URL. Anybody have any ideas?
<form role="form" method="post" action="../controller/AddPerson.php">
<div class="box-body">
<div class="form-group">
<label for="newReservationFirstName"> First name</label>
<input type="text" class="form-control" name="newReservationFirstName" placeholder="Enter first name">
<label for="newReservationLastName"> Last name</label>
<input type="text" class="form-control" name="newReservationLastName" placeholder="Enter last name">
<label for="newReservationPhoneNumber"> Phone Number</label>
<div class="input-group">
<div class="input-group-addon">
<i class="fa fa-phone"></i>
</div>
<input type="text" class="form-control" name="newReservationPhoneNum" data-inputmask='"mask": "(999) 999-9999"' data-mask/>
</div><!-- /.input group -->
<label for="newReservationStreetAddress"> Street Address</label>
<input type="text" class="form-control" name="newReservationStreetAddress" placeholder="Enter street address">
<label for="newReservationCity"> City</label>
<input type="text" class="form-control" name="newReservationCity" placeholder="Enter city">
<label for="newReservationState"> State</label>
<select class="form-control" name="newReservationState">
<?php
$result = getTableOrderBy('States','stateName');
while($row = mysql_fetch_array($result)) {
echo "<option value=".$row[stateAbbr].">".$row[stateName]."</option>";
} ?>
</select>
<label for="newReservationZip"> Zip Code</label>
<input type="text" class="form-control" name="newReservationZip" placeholder="Enter zipcode">
</div>
<button type="submit" class="btn btn-success btn-lg">Add New Customer</button>
</div>
</form>
This is the form that doesn't work correctly, both pages exist on the server:
<form role="form" method="post" action="../controller/AddEmployee.php">
<div class="box-body">
<div class="form-group">
<label for="newEmployeeFirstName"> First name</label>
<input type="text" class="form-control" name="newEmployeeFirstName" placeholder="Enter first name">
<label for="newEmployeeLastName"> Last name</label>
<input type="text" class="form-control" name="newEmployeeLastName" placeholder="Enter last name">
<label for="newEmployeePhoneNumber"> Phone Number</label>
<div class="input-group">
<div class="input-group-addon">
<i class="fa fa-phone"></i>
</div>
<input type="text" class="form-control" name="newEmployeePhoneNum" data-inputmask='"mask": "(999) 999-9999"' data-mask/>
</div><!-- /.input group -->
<label for="newEmployeeStreetAddress"> Street Address</label>
<input type="text" class="form-control" name="newEmployeeStreetAddress" placeholder="Enter street address">
<label for="newEmployeeCity"> City</label>
<input type="text" class="form-control" name="newEmployeeCity" placeholder="Enter city">
<label for="newEmployeeState"> State</label>
<select class="form-control" name="newEmployeeState">
<?php
$result = getTableOrderBy('States','stateName');
while($row = mysql_fetch_array($result)) {
echo "<option value=".$row[stateAbbr].">".$row[stateName]."</option>";
} ?>
</select>
<label for="newEmployeeZip"> Zip Code</label>
<input type="text" class="form-control" name="newEmployeeZip" placeholder="Enter zipcode">
<p></p>
<p></p>
<label for="newEmployeeFirstName"> Account Username</label>
<input type="text" class="form-control" name="newEmployeeUsername" placeholder="Enter username">
<label for="newEmployeeLastName"> Account Password</label>
<input type="text" class="form-control" name="newEmployeePassword" placeholder="Enter password">
<label for="newEmployeePhoneNumber"> Social Security Number</label>
<input type="text" class="form-control" name="newEmployeeSocial" placeholder="Enter SSN">
<div class="form-group" name="newEmployeePrivileges">
<br>
Privileges :
<select name="newEmployeePrivileges">
<option value="admin">Admin</option>
<option value="admin">Non-Admin</option>
</select>
</div>
<button type="submit" class="btn btn-success btn-lg">Add New Employee</button>
</div>
</div>
</form>
----------------------------------EDIT ----------------------------------------------
I tried making a another really simple form on some extra space and it still didn't work. I have no idea what could be cause it to do this.
<form method="post" action="post" action="../controller/AddEmployee.php">
<button type="submit" class="btn btn-success btn-lg">Add New Employee</button>
</form>
It could be that the button tag you are using to submit the form is causing it behave strangely. Try swapping out the button tag for an input. So:
<form method="post" enctype="multipart/form-data" action="../controller/AddEmployee.php">
<input type="submit" class="btn btn-success btn-lg" name="submit" >Add New Employee</input>
</form>
Also, I noticed you've included two 'action' attributes in your example form :-)
I'm new in codeigniter
I try to add data in table users using ajax when I send data I have now problem and all data send good but no data stored in data base
and this is my code
controller
public function addusersajax()
{
if($this->input->post("action") =="addusersintable")
{
$this->load->helper('date');
$data=array(
"fullname"=> $this->input->post("fullname"),
"username"=> $this->input->post("username"),
"password" => md5($this->input->post("password")),
"email"=>$this->input->post("email"),
"groubid"=>$this->input->post("groubid"),
"date"=>mdate('%Y-%m-%d ', now()),
"time"=>date(" H:i:s")
);
$this->load->model("usersmodel");
if($this->usersmodel->adduserbyajax($data)){
echo "done";
}else{
echo 'failed';
}
}
}
this is function for view form
public function view()
{
$data['pagetitle']="xx";
$this->load->view("template/admin/header",$data);
$this->load->view("users/ss",$data);
$this->load->view("template/admin/footer");
}
this is my view
<div class="container">
<div id="container">
<div class="col-lg-8">
<form id="insercodegn" method="post" action="" enctype="multipart/form-data">
<div class="form-group">
<label for="recipient-name" class="control-label">Full Name :</label>
<input type="text" class="form-control" name="fullname" id="fullname" placeholder="please insert fullname" autocomplete="off" required="required">
</div>
<div class="form-group">
<label for="recipient-name" class="control-label">UserName :</label>
<input type="text" class="form-control" name="username" id="username" placeholder="please insert user name" autocomplete="off" required="required" >
</div>
<div class="form-group">
<label for="message-text" class="control-label">Password:</label>
<input type="password" class="form-control" name="password" id="password" placeholder="please insert yout password" autocomplete="new-password" required="required" >
<i class=" showpass fa fa-eye fa-3" aria-hidden="true"></i>
</div>
<div class="form-group">
<label for="recipient-name" class="control-label">Email :</label>
<input type="text" class="form-control" name="email" id="email" placeholder="please insert email" autocomplete="off" required="required" >
</div>
<div class="form-group">
<label for="recipient-name" class="control-label">User Type :</label>
<select class="form-control" name="groubid" id="groubid">
<option value="1">Administartor</option>
<option value="0">User</option>
<option value="2">Maker</option>
<option value="3">cheker</option>
</select>
</div>
<div class="form-group">
<label for="exampleInputFile">Image :</label>
</div>
<input type="submit" name="action" value="adduserssss">
<button type="submit" name="action" value="addusersintable" class="btn btn-primary">addcc</button>
</form>
</div>
</div>
</div>
****this is my script inside ss viewpage****
<script>
$(document).ready(function () {
$(function () {
$("#insercodegn").on('submit', function (e) {
e.preventDefault();
$.ajax({
url:'<?php echo base_url()?>Users/addusersajax',
//url:"<?php echo base_url() .'Users/addusersajax'?>",
method:'post',
data: new FormData(this),
contentType: false,
cache: false,
processData: false,
success:function(data) {
alert(data);
}
})
})
})
})
</script>
my form is
<div class="container">
<div id="container">
<div class="col-lg-8">
<form id="insercodegn" method="post" action="" enctype="multipart/form-data">
<div class="form-group">
<label for="recipient-name" class="control-label">Full Name :</label>
<input type="text" class="form-control" name="fullname" id="fullname" placeholder="please insert fullname" autocomplete="off" required="required">
</div>
<div class="form-group">
<label for="recipient-name" class="control-label">UserName :</label>
<input type="text" class="form-control" name="username" id="username" placeholder="please insert user name" autocomplete="off" required="required" >
</div>
<div class="form-group">
<label for="message-text" class="control-label">Password:</label>
<input type="password" class="form-control" name="password" id="password" placeholder="please insert yout password" autocomplete="new-password" required="required" >
<i class=" showpass fa fa-eye fa-3" aria-hidden="true"></i>
</div>
<div class="form-group">
<label for="recipient-name" class="control-label">Email :</label>
<input type="text" class="form-control" name="email" id="email" placeholder="please insert email" autocomplete="off" required="required" >
</div>
<div class="form-group">
<label for="recipient-name" class="control-label">User Type :</label>
<select class="form-control" name="groubid" id="groubid">
<option value="1">Administartor</option>
<option value="0">User</option>
<option value="2">Maker</option>
<option value="3">cheker</option>
</select>
</div>
<div class="form-group">
<label for="exampleInputFile">Image :</label>
</div>
<button type="submit" name="action" value="adduserssss" class="btn btn-primary">add</button>
</form>
</div>
</div>
</div>
Change this:
<input type="submit" name="action" value="adduserssss">
<button type="submit" name="action" value="addusersintable" class="btn btn-primary">addcc</button>
To this:
<input type="hidden" name="action" value="addusersintable">
<button type="submit" class="btn btn-primary">addcc</button>
Buttons don't have $_POST data thus: if($this->input->post("action") =="addusersintable") is always evaluating to false and never hitting your model. A hidden input is what you are looking for.
1) Use lower case url in your javascript file, try "users/addusersajax" instead of "Users/addusersajax".
2) Use var_dump($_POST) or print_r($_POST) in your controller. in network tab of Chrome or Firefox check to see result of your request. you must see what is posted. if it is all good you must check your model
3) In your model it is best to use transactions. see transactions documentations in Codeigniter user guide. also you can echo $this->db->last_query() to see what query is executed. copy the executed query and run it from phpMyAdmin or any other MySQL client you use and see if you get any error.