Insert data from modal, Codeigniter - codeigniter

I'm trying to insert the input data from a modal but I don't know how to achieve this. I'm not really familiar with AJAX(I apologize for that). I did some readings and research but I'm getting confused. Here is my modal content reserve_form.php
<form action="" id="book-form">
<div class="row flex-lg-row-reverse align-items-center pt-1">
<h3>Reservation Details</h3>
<div class="col-10 col-sm-8 col-lg-6">
<input type="hidden" name="package_id" value="<?php ?>">
<div class="form-group">
<label for="date_start" class="control-label">Reserve Date:</label>
<input type="date" name="date_start" id="date_start" class="form-control form-conrtrol-sm rounded-0" min="<?php echo date("Y-m-d") ?>" value="<?php echo date("Y-m-d") ?>" required>
</div>
<div id="msg" class="text-danger"></div>
<div id="check-availability-loader" class="d-none">
<center>
<div class="d-flex align-items-center col-md-6">
<strong>Checking Availability...</strong>
<div class="spinner-border ml-auto" role="status" aria-hidden="true"></div>
</div>
</center>
</div>
<div class="form-group">
<label for="quantity" class="control-label">Number of Person <span><i>(Max. of 15 person)</i></span></label>
<input type="number" class="form-control form" required name="person" value="">
</div>
<div class="form-group">
<label for="amount" class="control-label">Additional Inclusions</label>
<div>
<input type="checkbox" id="inclusion" name="inclusion" value="">
<label for="inclusion"> Unlimited Samgyupsal & Al Fresco dining experience</label>
</div>
</div>
<div class="form-group">
<label for="amount" class="control-label">Total Amount</label>
<input type="number" name="cost" id="amount" class="form-control form-conrtrol-sm rounded-0 text-right" value="<?php echo isset($cost) ? number_format($cost, 2) : 0.00 ?>" required readonly>
</div>
</div>
<div class="col-lg-6">
<div class="form-group">
<label for="name" class="control-label">First Name</label>
<input type="text" class="form-control mb-3" name="firstname" placeholder="Enter First Name" value="">
</div>
<div class="form-group">
<label for="name" class="control-label">Last Name</label>
<input type="text" class="form-control mb-3" name="lastname" placeholder="Enter Last Name" value="">
</div>
<div class="form-group">
<label for="name" class="control-label">Contact</label>
<input type="text" class="form-control mb-3" name="contact" placeholder="09xx-xxx-xxxx" value="">
</div>
<div class="form-group">
<label for="name" class="control-label">Email</label>
<input type="text" class="form-control mb-3" name="email" placeholder="example#email.com" value="">
</div>
</div>
</div>
<div class="modal-footer py-2">
<button class="btn btn-warning" type="submit" name="details">Save</button>
<button class="btn btn-secondary "><span class="close-sm">Close</span></button>
</div>
</form>
Here's my modal in view.php
<!-- Modal content -->
<div class="modal-content">
<div class="modal-header py-1">
<h3><?php echo $packages->title; ?></h3>
</div>
<div class="modal-body py-2">
<?php $this->load->view('forms/reserve_form'); ?>
</div>
</div>
Here' my Controller(page.php)
public function reservation_details()
{
$details = array();
$details2 = array();
if ($this->input->post('details')) {
$this->form_validation->set_rules('firstname', 'First Name', 'required');
$this->form_validation->set_rules('lastname', 'Last Name', 'required');
$this->form_validation->set_rules('contact', 'Contact', 'required');
$this->form_validation->set_rules('email', 'Email', 'required');
$this->form_validation->set_rules('date_start', 'Reserve Date', 'required');
$this->form_validation->set_rules('person', 'Number of Person', 'required|max_length[15]');
if ($this->form_validation->run() == true) {
$details = array(
'firstname' => $this->input->post('firstname'),
'lastname' => $this->input->post('lastname'),
'contact' => $this->input->post('contact'),
'email' => $this->input->post('email'),
);
$this->UI_model->reserve_details($details);
$details2 = array(
'date_start' => $this->input->post('date_start'),
'person' => $this->input->post('person'),
'inclusion' => $this->input->post('inclusion'),
);
$this->UI_model->reserve_add($details2);
}
}
}
Here's the Model
public function reserve_details(){
if (!empty($data)) {
$this->db->insert('clients', $data);
return $this->db->insert_id();
}
return false;
}
public function reserve_add(){
if (!empty($data)) {
$this->db->insert('book_list', $data);
return $this->db->insert_id();
}
return false;
}
Also, I'm trying to insert the data for multiple tables. Any help will be much appreciated. Thanks! Is is also fine to place the submit button at modal footer? or it should be at reserve.php?

You're passing data array through these functions.
$this->UI_model->reserve_details($details);
$this->UI_model->reserve_add($details2);
But in the model, you're not catching those.
public function reserve_details(){
public function reserve_add(){
So it should be
public function reserve_details($data){
public function reserve_add($data){
Since you're checking if (!empty($data)) { its always retuns false, unless Undefixed Varibale error.

Related

Once the password has been reset, I cannot log into my application

I'm following the documentation on this link about resetting the password:
Reset Password
So first I create the view containing a form just to request the email and once the email has been received I click on the button to reset the password.
So far everything ok! Once I reset the password I try to log into my app with the new password but I cannot log in with this new password.
Can anyone kindly tell me where the problem lies? Thank you all
Route:
Route::get('/forgot-password', [Controller::class,'passwordRequest'])->middleware('guest')->name('password.request');
Route::post('/forgot-password', [Controller::class,'passwordEmail'])->middleware('guest')->name('password.email');
Route::get('/reset-password/{token}', [Controller::class,'passwordReset'])->middleware('guest')->name('password.reset');
Route::post('/reset-password', [Controller::class,'passwordUpdate'])->middleware('guest')->name('password.update');
Controller:
public function passwordRequest() {
return view('auth.forgot-password');
}
public function passwordEmail(Request $request) {
$request->validate(['email' => 'required|email']);
$status = Password::sendResetLink(
$request->only('email')
);
return $status === Password::RESET_LINK_SENT
? back()->with(['status' => __($status)])
: back()->withErrors(['email' => __($status)]);
}
public function passwordReset($token) {
return view('auth.reset-password', ['token' => $token]);
}
public function passwordUpdate(Request $request) {
$request->validate([
'token' => 'required',
'email' => 'required|email',
'password' => 'required|min:8|confirmed',
]);
$status = Password::reset(
$request->only('email', 'password', 'password_confirmation', 'token'),
function ($user, $password) {
$user->forceFill([
'password' => Hash::make($password)
])->setRememberToken(Str::random(60));
$user->save();
event(new PasswordReset($user));
}
);
return $status === Password::PASSWORD_RESET
? redirect()->route('login')->with('status', __($status))
: back()->withErrors(['email' => [__($status)]]);
}
View:
ForgotPassword
<div class="row mt-3 mx-5">
<div class="col-12 col-md-6 namelabel">
<form action="{{route('password.email')}}" method="post">
#csrf
<div class="mb-3">
<label for="email" class="form-label">Email</label>
<input type="email" class="form-control" name="email">
</div>
<button type="submit" class="btn btn-primary mb-5">Invia</button>
</form>
</div>
</div>
ResetPassword
<div class="row mt-3 mx-5">
<div class="col-12 col-md-6 namelabel">
<form action="{{route('password.email')}}" method="post">
#csrf
<div class="mb-3">
<label for="email" class="form-label">Email</label>
<input type="email" class="form-control" name="email">
</div>
<div class="mb-3">
<label for="password" class="form-label">Password</label>
<input type="password" class="form-control" name="password">
</div>
<div class="mb-3">
<label for="password_confirmation" class="form-label">Conferma password</label>
<input type="password" class="form-control" name="password_confirmation">
</div>
<div class="mb-3">
<input type="hidden" class="form-control" name="token" value="{{$token}}" >
</div>
<button type="submit" class="btn btn-primary mb-5">Invia</button>
</form>
</div>
</div>
You're almost done! In your auth.reset-password view, you must send the request to the password.update route, not the password.email route.
The password.update route will run the passwordUpdate method to update the User's password.
https://laravel.com/docs/9.x/passwords#password-reset-handling-the-form-submission
<div class="row mt-3 mx-5">
<div class="col-12 col-md-6 namelabel">
<form action="{{ route('password.update') }}" method="post">
#csrf
<div class="mb-3">
<label for="email" class="form-label">Email</label>
<input type="email" class="form-control" name="email">
</div>
<div class="mb-3">
<label for="password" class="form-label">Password</label>
<input type="password" class="form-control" name="password">
</div>
<div class="mb-3">
<label for="password_confirmation" class="form-label">Conferma password</label>
<input type="password" class="form-control" name="password_confirmation">
</div>
<div class="mb-3">
<input type="hidden" class="form-control" name="token" value="{{$token}}" >
</div>
<button type="submit" class="btn btn-primary mb-5">Invia</button>
</form>
</div>
</div>

How to solve this error in laravel "Name and email address are required if not a client"

I'm getting an error as "Name and email address are required if not a client" while running the below mentioned code.
Find below the Controller Code:
class UserController extends Controller
{
public function insertform(){
return view('test');
}
public function create(){
$user=Whmcs::AddClient([
'firstname' => Input::get('firstname'),
'lastname' => Input::get('lastname'),
'email' => Input::get('email'),
'address1' => Input::get('address1'),
'city' => Input::get('city'),
'state' => Input::get('state'),
'postcode' => Input::get('postcode'),
'country' => Input::get('country'),
'phonenumber' => Input::get('phonenumber'),
'password2' => Input::get('password2'),
]);
return $user;
}
}
Find below the route code:
Route::get('insert', 'UserController#insertform');
Route::post('create', 'UserController#create')->name('user.create');
The blade file is given below
<div id="content" class="app-content" role="main">
<div class="app-content-body ">
<div class="bg-light lter b-b wrapper-md">
<h1 class="m-n font-thin h3">Sign up</h1>
</div>
<div class="wrapper-md" ng-controller="FormDemoCtrl">
<div class="row">
<div class="col-sm-12">
<div class="panel panel-default">
<div class="panel-heading font-bold">create an account</div>
<div class="panel-body">
<form class="bs-example form-horizontal" action="
{{route('user.create')}}" method="post">
<input type = "hidden" name = "_token" value = "<?php echo
csrf_token(); ?>">
<div class="form-group">
<label class="col-lg-2 control-label">firstname</label>
<div class="col-lg-6">
<input type="text" class="form-control" name="firstname"
placeholder="Name">
</div>
</div>
<div class="form-group">
<label class="col-lg-2 control-label">lastname</label>
<div class="col-lg-6">
<input type="text" class="form-control" name="lastname"
placeholder="Name">
</div>
</div>
<div class="form-group">
<label class="col-lg-2 control-label">Email</label>
<div class="col-lg-6">
<input type="email" class="form-control" name="email"
placeholder="Email">
</div>
</div>
<div class="form-group">
<label class="col-lg-2 control-label">address1</label>
<div class="col-lg-6">
<input type="text" class="form-control" name="address1"
placeholder="Subject">
</div>
</div>
<div class="form-group">
<label class="col-lg-2 control-label">city</label>
<div class="col-lg-6">
<select class="form-control" name="city">
<option value="-- Select --">-- Select --</option>
<option value="Coimbatore">Coimbatore</option>
<option value="Chennai">Chennai</option>
</select>
</div>
</div>
<div class="form-group">
<label class="col-lg-2 control-label">state</label>
<div class="col-lg-6">
<select class="form-control" name="state">
<option value="-- Select --">-- Select --</option>
<option value="Tamilnadu">Tamilnadu</option>
<option value="Andhra">Andhra</option>
<option value="Karnataka">Karnataka</option></select>
</div>
</div>
<div class="form-group">
<label class="col-lg-2 control-label">country</label>
<div class="col-lg-6">
<select class="form-control" name="country">
<option value="-- Select --">-- Select --</option>
<option value="India">India</option>
<option value="China">China</option>
<option value="Australia">Australia</option></select>
</div>
</div>
<div class="form-group">
<label class="col-lg-2 control-label">postcode</label>
<div class="col-lg-6">
<input type="text" class="form-control" name="postcode"
placeholder="postcode">
</div>
</div>
<div class="form-group">
<label class="col-lg-2 control-label">phonenumber</label>
<div class="col-lg-6">
<input type="text" class="form-control" name="phonenumber"
placeholder="phonenumber">
</div>
</div>
<div class="form-group">
<label class="col-lg-2 control-label">password</label>
<div class="col-lg-6">
<input type="password" class="form-control" name="password2"
placeholder="password">
</div>
</div>
<div class="form-group">
<div class="col-lg-offset-2 col-lg-10">
<button type="submit" class="btn btn-sm btn-
success">Login</button>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
When I run the above code I'm getting an error as below:
{"result":"error","message":"Name and email address are required if not a client"}
suggest me a solution to solve this and post the data in laravel.

How to retrieve the post value and validate in controller using laravel?

In my route file
Route::get('griev_reg_form', 'GrievanceRegisterController#show');
Route::post('griev_reg_form', 'GrievanceRegisterController#postdata');
and in controller
<?php
namespace App\Http\Controllers;
use Illuminate\Support\Facades\DB;
use Illuminate\Http\Request;
use App\Http\Requests;
use App\Http\Controllers\Controller;
use App\GrievanceRegister;
use App\Department;
use Input;
use Validator;
use Redirect;
use Session;
class GrievanceRegisterController extends Controller
{
public function show()
{
$departments = Department::orderBy('edesc','ASC')->get();
return view('griev_reg_form', array('departments' => $departments));
}
public function postdata()
{
$data = Input::all();
// print_r($data);
echo $name = Input::get('name');
$rules = array(
'name' => 'required',
'email_address' => 'required|email',
'g-recaptcha-response' => 'required|captcha',
);
$validator = Validator::make($data, $rules);
if ($validator->fails()){
echo "1";
return Redirect::to('/griev_reg_form')->withInput()->withErrors($validator);
}
else{
// Do your stuff.
}
}
}
?>
and in the view file
{!! Form::open(array('url'=>'griev_reg_form','method'=>'POST', 'id'=>'myform')) !!}
<div class="box-body">
<div class="form-group">
<label class="col-sm-3 control-label">Grievance Case:
</label>
<label>
<input type="radio" name="gretype" class="minimal" checked>
</label>
<label>Normal Case
</label>
<label>
<input type="radio" name="gretype" class="minimal">
</label>
<label>
NRI
</label>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">Grievance/Demand/Suggestion/Others:
</label>
<label>
<input type="radio" name="sugg_demand" class="minimal" checked value="G">
</label>
<label>Grievance
</label>
<label>
<input type="radio" name="sugg_demand" class="minimal" value="S">
</label>
<label>
Suggestion
</label>
<label>
<input type="radio" name="sugg_demand" class="minimal"
value="D">
</label>
<label>
Demand
</label>
<label>
<input type="radio" name="sugg_demand"
class="minimal" value="O">
</label>
<label>
Others
</label>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">Department/Office:
</label>
<select class="form-control select2" name="dept_name" style="width: 28%;">
<option value="">Select Department</option>
<?php
foreach($departments as $result)
{
?>
<option value="<?php echo $result->deptcode; ?>"><?php echo $result->edesc; ?></option>
<?php
}
?>
</select>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">Mobile No:</label>
<div class="input-group">
<div class="input-group-addon">
<i class="fa fa-phone"></i>
</div>
<input type="text" class="form-control" name="mobileno">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">Alternative Mobile No:</label>
<div class="input-group">
<div class="input-group-addon">
<i class="fa fa-phone"></i>
</div>
<input type="text" class="form-control" name="amobileno">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">Received Date:</label>
<div class="input-group date">
<div class="input-group-addon">
<i class="fa fa-calendar"></i>
</div>
<input type="text" class="form-control" name="recvd_date" id="datepicker" readonly="">
</div>
<!-- /.input group -->
</div>
<div class="form-group">
<label class="col-sm-3 control-label">Name:</label>
<input type="text" class="form-control" name="cname">
</div>
<div class="form-group">
<label class="col-sm-3 control-label">Individual or Group Complainant(s):
</label>
<label>
<input type="radio" name="indiv_grp" value="I" class="minimal" checked>
</label>
<label>Individual
</label>
<label>
<input type="radio" name="indiv_grp" value="G" class="minimal">
</label>
<label>Group
</label>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">AADHAR Card Number:</label>
<input type="text" class="form-control" name="idproofdetail">
</div>
<div class="form-group">
<label class="col-sm-3 control-label">Address:</label>
<input type="text" class="form-control" name="address1">
</div>
<div class="form-group">
<input type="text" class="form-control box-right" name="address2">
</div>
<div class="form-group">
<input type="text" class="form-control box-right" name="address3">
</div>
<div class="form-group">
<label class="col-sm-3 control-label">Pin code:</label>
<input type="text" class="form-control" name="pincode">
</div>
<div class="form-group">
<label class="col-sm-3 control-label">Email:</label>
<div class="input-group">
<span class="input-group-addon"><i class="fa fa-envelope"></i></span>
<input type="email" class="form-control" placeholder="Email" name="email_address">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">District:
</label>
<select class="form-control select2" name="district_problem" style="width: 28%;">
</select>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">विधानसभा निर्वाचन क्षेत्र /Assembly Constituency:
</label>
<select class="form-control select2" name="ac_problem" style="width: 28%;">
</select>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">Area:
</label>
<label>
<input type="radio" value="urban" name="problem_area" class="minimal" checked>
</label>
<label>Urban
</label>
<label>
<input type="radio" value="rural" name="problem_area" class="minimal">
</label>
<label>
Rural
</label>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">Town/Block:
</label>
<select class="form-control select2" name="city_problem" style="width: 28%;">
</select>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">Please Enter Specific Details about Your Grievance </label>
<textarea class="form-control" rows="3" name="Description" placeholder="Enter ..."></textarea>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">What do you want?</label>
<textarea class="form-control" rows="3" name="remedies" placeholder="Enter ..."></textarea>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">Upload(Relevant Document):</label>
<input type="file" class="form-control">
</div>
<div class="form-group">
<label class="col-sm-3 control-label">Captcha</label>
<label class="col-sm-3 control-label">
{!! app('captcha')->display(); !!}
</label>
</div>
<div class="form-group">
<div class="col-md-6 col-md-offset-4">
<button type="submit" class="btn btn-primary">
Submit
</button>
</div>
</div>
</form>
when i click on submit button without filling any data, its doesn't go
on validation part
Please provide help how can i check the post value of input fileds as well as
captcha and also validate accordingly
I have checked your view..I didnt find any input field named as "name", you have "cname" so maybe you validation rule should be:
$rules = array(
'cname' => 'required',
'email_address' => 'required|email',
'g-recaptcha-response' => 'required|captcha'
);
In case you are using >=5.3 version then you should use:
public function postdata(Request $request)
{
//validation
$validationArray = [
'cname' => 'required',
'email_address' => 'required|email',
'g-recaptcha-response' => 'required|captcha'
];
$validator = Validator::make($request->all(),$validationArray);
if ($validator->fails()) {
$response = ['errors' => $validator->messages()->all()];
return Response::json($response,200);
}
//here if validation is successful
}
Ofcourse add at top of controller: use Illuminate\Http\Request;

Laravel 5.2 cannot update record

I cannot seem to update my record.
My controller
public function add()
{
return view('cars.add');
}
public function edit($id)
{
$car = Cars::whereId($id)->firstOrFail();
return view('cars.edit', compact('car'));
}
public function store(CarFormRequest $request)
{
$car = new Cars(array(
'name' => $request->get('name'),
'color_id' => $request->get('color')
));
$car->save();
$car->position_id = $car->id;
$car->save();
session()->flash('status', 'Successfully Added a Car!');
return view('cars.add');
}
public function update($id, CarFormRequest $request)
{
$car = car::whereId($id)->firstOrFail();
$car->name = $request->get('name');
$car->color_id = $request->get('color');
if($request->get('status') != null) {
$car->status = 0;
} else {
$car->status = 1;
}
$car->save();
return redirect(action('CarController#edit', $car->id))->with('status', 'The ticket '.$id.' has been updated!');
}
my routes:
Route::get('/', 'PagesController#home');
Route::get('/about', 'PagesController#about');
Route::get('/contact', 'PagesController#contact');
Route::get('/cars', 'CarsController#index');
Route::get('/cars/edit/{id?}', 'CarsController#edit');
Route::post('/cars/edit/{id?}', 'CarsController#update');
Route::get('/cars/add', 'CarsController#add');
Route::post('/cars/add', 'CarsController#store');
here is my view:
<div class="container col-md-8 col-md-offset-2">
<div class="well well bs-component">
<form class="form-horizontal" method="post">
<input type="hidden" name="_token" value="{!! csrf_token() !!}">
<input type="text" id="color_id" name="color_id" value="{!! $car->color_id !!}">
<fieldset>
<legend>Edit Car Information</legend>
<div class="form-group">
<label for="title" class="col-lg-2 control-label">Car Name</label>
<div class="col-lg-10">
<input type="text" value="{{ $car->name }}" class="form-control" id="name" placeholder="Car Name">
</div>
</div>
<div class="form-group">
<label for="title" class="col-lg-2 control-label">Car Color</label>
<div class="col-lg-10">
<div class="btn-group" data-toggle="buttons">
<label id="opt1" class="btn btn-primary">
<input type="radio" name="color" id="option1" autocomplete="off"> Red
</label>
<label id="opt2" class="btn btn-primary">
<input type="radio" name="color" id="option2" autocomplete="off"> Blue
</label>
<label id="opt3" class="btn btn-primary">
<input type="radio" name="color" id="option3" autocomplete="off"> Yellow
</label>
<label id="opt4" class="btn btn-primary">
<input type="radio" name="color" id="option4" autocomplete="off"> Green
</label>
<label id="opt5" class="btn btn-primary">
<input type="radio" name="color" id="option5" autocomplete="off"> Black
</label>
<label id="opt6" class="btn btn-primary">
<input type="radio" name="color" id="option6" autocomplete="off"> White
</label>
</div>
</div>
</div>
<div class="form-group">
<div class="col-lg-10 col-lg-offset-2">
<button class="btn btn-default">Cancel</button>
<button type="submit" class="btn btn-primary">Submit</button>
</div>
</div>
</fieldset>
</form>
</div>
</div>
The $id variable in whereIn must be array and you need to specify the database column too. This should be like -
public function edit($id)
{
$car = Cars::whereId('id', [$id])->firstOrFail();
return view('cars.edit', compact('car'));
}
Change all occurrence of
$car = car::whereId($id)->firstOrFail();

Fields does not Update in laravel5

I am working on Laravel Form data Updation with image update. Now here my image only update smoothly in my DB. But other field does not update. anyone can identify what is my mistake? i attached my code below:
Controller
public function siteadmin_update_ads(Request $request)
{
$post = $request->all();
$cid=$post['id'];
$name = $post['ads_title'];
$url = $post['ads_url'];
$img=Input::file('ads_image');;
$v=validator::make($request->all(),
[
'ads_title'=>'required',
'ads_url' => 'required',
'ads_image'=> 'required'
]
);
if($v->fails())
{
return redirect()->back()->withErrors($v->errors());
}
else
{
if($img->isvalid())
{
$extension=$img->getClientOriginalName();
$move_img = explode('.',$extension);
$fileName=$move_img[0].str_random(8).".".$move_img[1];
$destinationPath = '../assets/adsimage/';
$uploadSuccess=Input::file('ads_image')->move($destinationPath,$fileName);
$data=array(
'ads_title'=> $name,
'ads_url'=> $url,
'ads_image'=>$fileName,
);
$i=Ads_model::update_ads($data,$cid);
if($i>0)
{
Session::flash ('message_update', 'Record Updated Successfully');
return redirect('siteadmin_manageads');
}
}
else {
return Redirect('siteadmin_editads');
}
}
}
Model
public static function update_ads($data,$cid)
{
return DB::table('le_ads')->where('id',$cid)->update($data);
}
View
<form class="form-horizontal form-label-left" id="myform" novalidate method="POST" action="{{action('SiteadminController#siteadmin_update_ads')}}" enctype="multipart/form-data">
<input type="hidden" name="_token" value="<?php echo csrf_token(); ?>">
<input type="hidden" class="form-control" name="id" value="<?php echo $row->id ?>" id="id">
<div class="item form-group">
<label class="control-label col-md-3 col-sm-3 col-xs-12" for="name">Ad Title<span class="required">*</span>
</label>
<div class="col-md-6 col-sm-6 col-xs-12">
<input id="name" class="form- control col-md-7 col-xs-12" data-validate-length-range="3" name="ads_title" placeholder="Ad Title" required type="text" value="<?php echo $row->ads_title ?>">
</div>
</div>
<div class="item form-group">
<label class="control-label col-md-3 col-sm-3 col-xs-12">Upload Image*</label>
<div class="col-md-9 col-sm-6 col-xs-12">
<input type='file' id="field" class='demo left' name='ads_image' data-type='image' data-max-size='2mb'/><br>
<img src="{{ url('../assets/adsimage/').'/'.$row->ads_image}}" style="height:90px;">
</div>
</div>
<div class="item form-group">
<label class="control-label col-md-3 col-sm-3 col-xs-12" for="name">Redirect URL<span class="required">*</span>
</label>
<div class="col-md-6 col-sm-6 col-xs-12">
<input id="name" class="form-control col-md-7 col-xs-12" data-validate-length-range="3" name="ads_url" placeholder="Redirect URL" required type="url" value="<?php echo $row->ads_url ?>">
</div>
</div>
<div class="item form-group">
<div class="col-md-3"></div>
<div class="col-md-2 col-sm-6 col-xs-12">
<button class="btn btn-block btn-success" type="submit">Update</button>
</div>
<div class="col-md-2 col-sm-6 col-xs-12">
<button class="btn btn-block btn-danger" type="reset">Cancel</button>
</div>
</div>
</form>

Resources