Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable, creative experience to be truly fulfilling.
Original source
Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable, creative experience to be truly fulfilling.
Original source
38 responses to “Laravel 5 tutorial, How To Insert Data in Database”
Hello Friend need to complete 1K Subscribers please help me and support to reach there.
Please Subscribe channel and support us.
moh sy tora buk beh leya kro
hey man, Wheres the error handling for that?
on laravel 5.7 this not support, right?
Thank you bro
The requested URL was not found on this server. Sir yeh error arhaa haii 🙁 Kindly help me in solving this
Hello Sr see this the error that I got "Class 'AppHttpControllersdb' not found" could help me?
The requested URL /insert was not found on this server.
Very Nice Thanks Friend,
kbc all media work in web design http://www.cromosoft.in
this helping me a lot , today i try to inset the data to the mssql database : i use $product = new product;
$product->pro_name = $request->pro_name;
$product->pro_code = $request->pro_code;
$product->pro_price = $request->pro_price;
$product->pro_info = $request->pro_info;
$product->pro_img = $filename;
$product->spl_price = $request->spl_price;
$product->save(); then Error message keep saying in MSsql server invalid object name [products] , so i try u formal ,and it works , thank for you video tutorial.
this tutorial controller page do not import for database library.
you can add import your code in controller page for input database :
namespace AppHttpControllers;
use IlluminateHttpRequest;
use AppHttpRequests;
use IlluminateSupportFacadesDB;
I give example of contolller page
<?php
namespace AppHttpControllers;
use IlluminateHttpRequest;
use AppHttpRequests;
use IlluminateSupportFacadesDB;
class RegController extends Controller
{
//
public function reg(){
return view('Registration');
}
public function insert(Request $req){
$student_id = $req->input('student_id');
$course_code = $req->input('course_code');
$course_title = $req->input('course_title');
$course_credit = $req->input('course_credit');
$data = array('student_id'=> $student_id ,'course_code'=>$course_code,'course_title'=>$course_title,'course_credit'=>$course_credit );
DB::table('course')->insert($data);
return back();
}
}
if I didn't put any input then the laravel will get error. how to change it to show echo that all data must be filled. thanks
how about table schema, something like migrate. Did i miss anything or we dont required it
Everyone, use
form action="{{ action('Controller@insert')}}"
INSTEAD OF
form action="/insert"
It will work fine.
Justo lo que buscaba, gracias
100% Perfectly Worked !!
Thank U Very Much Bro !! 😀
And Plz create a Video How to Edit Data in Database..
Bhai Where the f*** is model, damn kuch bhi code karke save karo?
Better if work on core php if planing to work in this way…
broo, there is noo edit??
if you follow all the instructions step by step it works like a charm! you a re getting a new subscriber
Hi Amit… ur video is awsome but its not working ..its running and error is ..url line is http://localhost:8000/insert
show is in url insert,,,,Sorry, the page you are looking for could not be found.
sir, i got an error… please hlp me..
ReflectionException in Route.php line 286:
Class AppHttpControllersRequest does not exist
Please, don't waste you time – doesn't work
Hope u saved 10 min of your life
Sir I get this error and please solve this – (1/1) ErrorException Undefined variable: req in controller
sir how to give session in a login page..
may it easy.But i dnt know how to set it.
tank u very much sir…..
i liked this tutorial, i tried it and its working, but i have a problem with the last part, where the data is to be added to the database, but mine is showing error….
awesome bru..you got one subscriber..
Hello Amit, do u know how to save a multiple rows of records from one database table to another table at the same database? Thanks.
The requested URL /insert was not found on this server. what should i do sir
how to fixed it.
QueryException in Connection.php line 647:
SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'country_code' cannot be null (SQL: insert into `location` (`country_code`, `country`, `city_region`, `zip`) values (, , , ))
Can you do a tutorial on a 'favourite' system, so maybe there's some data (for example a charity), and the current user wants to add that charity to their favourites list. Their favourites list could be displayed on their profile page?
thank you so much really !
I was searching for such kind of tutorials. Now i have one question, after the insert statement you are directly writing echo statement. How to validate if there is an error in your query.
for use DB::table('mesajlar')->insert($data); you need to write
"use DB;" after namespace
Route::any('/insert','Controller@method');
Try this one @Tolunay Toprakkaya
Web.php
Route::get('/', function () {
return view('insertForm');
});
Route::post('/insert', 'Controller@insert');
——————————————————-
Controller.php
<?php
namespace AppHttpControllers;
use IlluminateFoundationBusDispatchesJobs;
use IlluminateRoutingController as BaseController;
use IlluminateFoundationValidationValidatesRequests;
use IlluminateFoundationAuthAccessAuthorizesRequests;
class Controller extends BaseController
{
use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
function insert(Request $req)
{
$email = $req -> input('email');
$mesaj = $req -> input('mesaj');
$data = array('email'=>$email, "mesaj"=>$mesaj);
DB::table('mesajlar')->insert($data);
echo "Mesaj Gönderildi";
}
}
————————————–
insertForm.blade.php
<!DOCTYPE html>
<html>
<head>
<title>Insert Form</title>
</head>
<body>
<center>
<form action="/insert" method="post">
<table>
<tr>
{{ csrf_field() }}
<td>E-Mail : </td>
<td><input type="text" name="email"></td>
</tr>
<tr>
<td>Mesaj : </td>
<td><textarea rows="4" cols="20" name="mesaj"></textarea></td>
</tr>
<tr>
<td><input type="submit" name="submit" value="Gönder"></td>
</tr>
</table>
</form>
</center>
</body>
</html>
Everything looking good but i have a problem The requested URL /insert was not found on this server. It is not see /insert HELP ME PLS
Sir Love you <3 , your tutorial is love
Nice tutorial video! I leave my 'like' for this. And already sub to your channel 🙂 Would be nice if you could check me out too 🙂