I was wondering if there is any way I can display more than one fields in the autocomplete search box. It already search for fist and last name but when the user types the last name it shows only the first name. But I wonder if there is a way that I can also display the last name or address on the search result. I am only getting the id of the guardian because it's the only thing I need to sent to the database. Here is a look at my code:
This is my function for the autocomplete:
public function autocomplete(Request $request)
{
$term=$request->term;
$data = Guardian::orWhere('first_name','LIKE','%'.$term.'%')
->orWhere('last_name','LIKE','%'.$term.'%')
->take(10)->get();
$results=array();
foreach($data as $key => $v)
{
$results[]=['id'=>$v->idguardian, 'value'=>$v->first_name];
}
return response()->json($results);
}
My view:
<div class="row">
<div class="col-md-6">
<h3>New Kid</h3>
<p> Please search the guardian name for the kid. If the guardian isn't registered please add it</p>
<form action="{{route('createkid')}}" method="post">
<div class="form-group">
<input type="text" name="searchname" class="form-control" id="searchname" placeholder="Search">
<tr>
<td>ID</td>
<td><input type="text" name="idguardian" id="idguardian" class="form-control"></td>
</tr>
<tr>
<td></td>
<td></td>
</tr>
</div>
<a href="{{URL::to('addguardian/list/')}}" class="btn btn-success btn-xs" >Add Guardian</a>
<div class ="form-group">
<label for="first_name">First Name</label>
<input type="text" name="first_name" class="form-control" placeholder="FirstName">
</div>
<div class ="form-group">
<label for="middle_name">Middle Name</label>
<input type="text" name="middle_name" class="form-control" placeholder="MiddleName">
</div>
<div class ="form-group">
<label for="last_name">Last Name</label>
<input type="text" name="last_name" class="form-control" placeholder="LastName">
</div>
<div class ="form-group">
<label for="dateofbirth">Date Of Birth</label>
<input type="text" name="dateofbirth" class="form-control" placeholder="DateOfBirth">
</div>
<div class ="form-group">
<label for="sex">Sex</label>
<input type="text" name="sex" class="form-control" placeholder="Sex">
</div>
<div class ="form-group">
<label for="age">Age</label>
<input type="text" name="age" class="form-control" placeholder="Age">
</div>
<div class ="form-group">
<label for="schoolname">School Name</label>
<input type="text" name="schoolname" class="form-control" placeholder="SchoolName">
</div>
<div class ="form-group">
<label for="schoolgrade">School Grade</label>
<input type="text" name="schoolgrade" class="form-control" placeholder="SchoolGrade">
</div>
<div class ="form-group">
<label for="schoolgroup">School Group</label>
<input type="text" name="schoolgroup" class="form-control" placeholder="SchoolGroup">
</div>
<div class ="form-group">
<label for="bloodtype">Blood Type</label>
<input type="text" name="bloodtype" class="form-control" placeholder="BloodType">
</div>
<div class ="form-group">
<label for="allergies">Allergies</label>
<input type="text" name="allergies" class="form-control" placeholder="Allergies">
</div>
<div class ="form-group">
<label for="enroll_date">Enroll Date</label>
<input type="text" name="enroll_date" class="form-control" placeholder="EnrollDate">
</div>
<div class="form-group">
{!! Form::label('iduser','Select User') !!}
{!! Form::select('iduser', $kids, ['class' => 'form-control']) !!}
</div>
<button type="submit" class="btn btn-primary">Submit</button>
<input type="hidden" name="_token" value="{{ Session::token()}}">
</form>
</div>
</div>
<script type="text/javascript">
$("#searchname").autocomplete({
source : '{!!URL::route('autocomplete')!!}',
minLenght:1,
autoFocus:true,
select:function(e, ui){
$('#idguardian').val(ui.item.id);
}
});
</script>
My Route:
Route::get('/autocomplete',array('as'=>'autocomplete','uses'=>'KidsController#autocomplete'));
I really hope you can help me. Thank you!
Why not just append the last name onto the first name?
public function autocomplete(Request $request)
{
$term=$request->term;
$data = Guardian::orWhere('first_name','LIKE','%'.$term.'%')
->orWhere('last_name','LIKE','%'.$term.'%')
->take(10)->get();
$results=array();
foreach($data as $key => $v)
{
$results[]=['id'=>$v->idguardian, 'value'=>$v->first_name . ' ' . $v->last_name];
}
return response()->json($results);
}
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
This is my edit method:
public function edit(User $user)
{
// ...
return view('admin.biodata.edit',
[
'title' => 'Edit Biodata',
'active' => 'biodata',
'majors' => Major::all(),
'biodata' => $user
]
);
}
edit.blade.php
#extends('admin.adminDashboard.layouts.main')
#section('container')
<div class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pt-3 pb-2"></div>
<h1>Edit Student</h1>
<div class="container">
<form action="{{url('admin/biodata')}}" method="POST">
#csrf
<input type="hidden" name="id" value="{{ $biodata->id }}">
<div class="form-group">
<label for="name">Name</label>
<input type="text" class="form-control" id="name" name="name" placeholder="Enter name" value="{{$biodata->name}}">
</div>
<div class="form-group">
<label for="nrp">NRP</label>
<input type="text" class="form-control" id="nrp" name="nrp" placeholder="Enter NRP" value="{{$biodata->nrp}}">
</div>
<div class="form-group">
<label for="email">Email</label>
<input type="email" class="form-control" id="email" name="email" placeholder="Enter email" value="{{$biodata->email}}">
</div>
<div class="form-group">
<label for="address">Address</label>
<input type="text" class="form-control" id="address" name="address" placeholder="Enter address" value="{{$biodata->address}}">
</div>
<div class="form-group">
<label for="generation">Generation</label>
<input type="text" class="form-control" id="generation" name="generation" placeholder="Enter generation" value="{{$biodata->generation}}">
</div>
<div class="form-group">
<label for="major">Major</label>
<select class="form-control" id="major" name="major_id">
#foreach ($majors as $major)
<option value="{{$major->id}}">{{$major->nama_jurusan}}</option>
#endforeach
</select>
</div>
<button type="submit" class="btn btn-primary">Submit</button>
</form>
#endsection
When I press the edit button from the index view, the old data is not displayed in the view admin.biodata.edit. I thought I have already passed the user data through the biodata variable.
Replace the value in the template with
value="{{old('name',$biodata->name)}}"
i add a new table using the voyager database menu. the problem is that i can't create new data with my newly created database... anytime i try to insert a new data, its only the created_at and Updated_at column that is populated
and the code:
<form clas[s="form-edit-add" role="form"][1]
action="#if(isset($dataTypeContent->id)){{
route('voyager.'.$dataType->slug.'.update', $dataTypeContent->id) }}#else{{
route('voyager.'.$dataType->slug.'.store') }}#endif"
method="POST" enctype="multipart/form-data">
<!-- PUT Method if we are editing -->
#if(isset($dataTypeContent->id))
{{ method_field("PUT") }}
#endif
<!-- CSRF TOKEN -->
{{ csrf_field() }}
<div class="panel-body">
<div class="form-group">
<label for="name">Staff_id</label>
<input type="text" class="form-control"
name="Staff_id"
placeholder="Staff_id" id="Staff_id"
value="#if(isset($dataTypeContent-
>Staff_id)){{ old('Staff_id', $dataTypeContent->Staff_id)
}}#else{{old('Staff_id')}}#endif">
</div>
<div class="form-group">
<label for="name">Title</label>
<input type="text" class="form-control"
name="title"
placeholder="title" id="title"
value="#if(isset($dataTypeContent-
>title)){{ old('title', $dataTypeContent->title)
}}#else{{old('title')}}#endif">
</div>
div class="form-group">
<label for="name">First_Name</label>
<input type="text" class="form-control"
name="first_name"
placeholder="first_name" id="first_name"
value="#if(isset($dataTypeContent-
>first_name)){{ old('first_name', $dataTypeContent->first_name)
}}#else{{old('first_name')}}#endif">
</div>
<div class="form-group">
<label for="name">Middle_Name</label>
<input type="text" class="form-control"
name="middle_name"
placeholder="middle_Name"
id="middle_name"
value="#if(isset($dataTypeContent-
>middle_name)){{ old('middle_name', $dataTypeContent->middle_name)
}}#else{{old('middle_name')}}#endif">
</div>
<div class="form-group">
<label for="name">Last_Name</label>
<input type="text" class="form-control"
name="last_name"
placeholder="Last_Name" id="last_name"
value="#if(isset($dataTypeContent-
>last_name)){{ old('last_name', $dataTypeContent->last_name)
}}#else{{old('last_name')}}#endif">
</div>
<div class="form-group">
<label for="name">Gender</label>
<input type="text" class="form-control"
name="gender"
placeholder="gender" id="gender"
value="#if(isset($dataTypeContent-
>gender)){{ old('gender', $dataTypeContent->gender)
}}#else{{old('gender')}}#endif">
</div>
<div class="form-group">
<label for="name">DOB</label>
<input type="text" class="form-control"
name="dob"
placeholder="dob" id="dob"
value="#if(isset($dataTypeContent->dob))
{{ old('dob', $dataTypeContent->dob) }}#else{{old('dob')}}#endif">
</div>
<div class="form-group">
<label for="name">Phone_Number</label>
<input type="text" class="form-control"
name="phone_number"
placeholder="phone_number"
id="phone_number"
value="#if(isset($dataTypeContent-
>phone_number)){{ old('phone_number', $dataTypeContent->phone_number)
}}#else{{old('phone_number')}}#endif">
</div>
<div class="form-group">
<label for="name">Unit</label>
<input type="text" class="form-control"
name="unit"
placeholder="unit" id="unit"
value="#if(isset($dataTypeContent->unit))
{{ old('unit', $dataTypeContent->unit)
}}#else{{old('unit')}}#endif">
</div>
<div class="form-group">
<label for="name">Department</label>
<input type="text" class="form-control"
name="department"
placeholder="department" id="department"
value="#if(isset($dataTypeContent-
>department)){{ old('department', $dataTypeContent->department)
}}#else{{old('department')}}#endif">
</div>
<div class="form-group">
<label for="name">Company</label>
<input type="text" class="form-control"
name="company"
placeholder="company" id="company"
value="#if(isset($dataTypeContent-
>company)){{ old('company', $dataTypeContent->company)
}}#else{{old('company')}}#endif">
</div>
<div class="form-group">
<label for="name">Employment_status</label>
<input type="text" class="form-control"
name="employment_status"
placeholder="employment_status"
id="employment_status"
value="#if(isset($dataTypeContent-
>employment_status)){{ old('employment_status', $dataTypeContent-
>employment_status) }}#else{{old('employment_status')}}#endif">
</div>
<div class="form-group">
<label for="name">Guarantor1</label>
<input type="text" class="form-control"
name="guarantor1"
placeholder="guarantor1" id="guarantor1"
value="#if(isset($dataTypeContent-
>guarantor1)){{ old('guarantor1', $dataTypeContent->guarantor1)
}}#else{{old('guarantor1')}}#endif">
</div>
<div class="form-group">
<label for="name">Guarantor2</label>
<input type="text" class="form-control"
name="guarantor2"
placeholder="guarantor2" id="guarantor2"
value="#if(isset($dataTypeContent-
>guarantor2)){{ old('guarantor2', $dataTypeContent->guarantor2)
}}#else{{old('guarantor2')}}#endif">
</div>
<div class="form-group">
<label for="name">Academic_record</label>
<input type="text" class="form-control"
name="academic_record"
placeholder="academic_record"
id="academic_record"
value="#if(isset($dataTypeContent-
>academic_record)){{ old('academic_record', $dataTypeContent-
>academic_record) }}#else{{old('academic_record')}}#endif">
</div>
<div class="form-group">
<label for="name">Work Experience</label>
<input type="text" class="form-control"
name="work_experience"
placeholder="work_experience"
id="work_experience"
value="#if(isset($dataTypeContent-
>work_experience)){{ old('work_experience', $dataTypeContent-
>work_experience) }}#else{{old('work_experience')}}#endif">
</div>
<div class="form-group">
<label for="name">Note</label>
<input type="text" class="form-control"
name="notes"
placeholder="notes" id="notes"
value="#if(isset($dataTypeContent-
>notes)){{ old('notes', $dataTypeContent->notes)
}}#else{{old('notes')}}#endif">
</div>
</div><!-- panel-body -->
<div class="panel-footer">
<button type="submit" class="btn btn-
primary">Submit</button>
</div>
</form>
<iframe id="form_target" name="form_target"
style="display:none"></iframe>
<form id="my_form" action="{{ route('voyager.upload') }}"
target="form_target" method="post"
enctype="multipart/form-data"
style="width:0;height:0;overflow:hidden">
{{ csrf_field() }}
<input name="image" id="upload_file" type="file"
onchange="$('#my_form').submit();this.value='';">
<input type="hidden" name="type_slug" id="type_slug"
value="{{ $dataType->slug }}">
</form>
this is my Model code for the Profiles table:
<?php
namespace TCG\Voyager\Models;
use Illuminate\Database\Eloquent\Model;
use TCG\Voyager\Facades\Voyager;
class Profile extends Model
{
protected $table = 'profiles';
protected $fillable = [
'Staff_id',
'Title',
'First_name',
'Middle_name',
'last_name',
'Gender',
'DOB',
'Phone_number',
'Company',
'Department',
'Unit',
'Date_employed',
'Date_of_exit',
'Mode_of_exit',
'Employment_Status',
'Guarantor1_Details',
'Guarantor2_Details',
'Academic_Record',
'Work_Experience',
'Notes',
];
}
Add this line to the model to allow the remaining data to enter the database
protected $fillable = ['name_of_column', 'name_of_thenextcolumn'];
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.