当我试图发布数据时,我得到的错误很多次,例如未定义的变量。我不知道错误在哪里,甚至数据都没有发布到数据库。我希望你能帮助解决这个错误。如果有修改请告诉我。
File.php
<form action="/create" method="post">
<input type="hidden" name="_token" value="<?php echo csrf_token(); ?>">
<div class="form">
<h3>Lead Information</h3>
<input type="text" name="fname" placeholder="First Name"/>
<input type="text" name="lname" placeholder="Last Name"/>
<input type="text" name="desig" placeholder="Designation"/>
<input type="email" name="email" placeholder="Email ID"/>
<input type="text" name="telephone"placeholder="telephone"/>
<input type="text" name="mobile" placeholder="Mobile"/>
<input type="text" name="linkedin"placeholder="Linked In">
<select name="priority">
<option >Priority</option>
<option >TBD</option>
<option >Hot</option>
<option >Warm</option>
<option>Cold</option>
<option>Dead</option>
</select>
<select name="leadsta">
<option >Lead Status</option>
<option >Attempt to Contact</option>
<option >Contact in Future</option>
<option>Contacted</option>
<option>Engaged in dialogue</option>
<option>Junk Lead</option>
<option>Lost Lead</option>
<option>Not Contacted</option>
<option>prequalified</option>
</select>
<input type="text" name="skype"placeholder="Skype">
</div>
<div class="form">
<h3>Company Information</h3>
<input type="text" name="cname"placeholder="Comapny Name"/>
<input type="url" name="website"placeholder="Website"/>
<input type="text" name="domain"placeholder="Domain"/>
<input type="text" name="anualrev"placeholder="Annual Revenue"/>
<input type="text" name="nemp"placeholder="No. of Employess"/>
<input type="text" name="street"placeholder="Street"/>
<input type="text" name="city"placeholder="City">
<input type="text" name="state"placeholder="State">
<input type="text" name="zip"placeholder="Zipcode">
<input type="text" name="country"placeholder="Country">
<input type="text" name="gdesc"placeholder="General Description">
<input type="text" name="cskype"placeholder="Skype">
<br>
<button input type="submit" name="submit"value="Add">Submit</button>
</form>
</div>
位指示
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use DB;
use App\Http\Requests;
class crmcontroller extends Controller
{
public function addleads(){
return view('forms.leads.add');
}
public function insert(Request $request){
$name = $request->input('forms.leads.add');
DB::insert('insert into leadlist (fname,lname,$desig,email,telephone,mobile,linkedin,priority,ledsta,skype,cname,website,domain,anualrev,nemp,street,city,state,zip,country,gdesc,cskype) values(?)',[$fname,$lname,$desig,$email,$telephone,$mobile,$linkedin,$priority,$ledsta,$skype,$cname,$website,$domain,$anualrev,$nemp,$street,$city,$state,$zip,$country,$gdesc,$cskype]);
echo "Record inserted successfully.<br/>";
echo '<a href="/insert">Click Here</a> to go back.';
}
}
routes.php文件
Route::get('leadsadd','crmcontroller@addleads');
Route::post('create','crmcontroller@insert');
提前感谢您的帮助。
答案 0 :(得分:1)
感谢您的帮助,最后我几天前得到了解决方案。 在这里我已经改变了控制器功能插入到它然后它正在工作。
public function insert(Request $request){
DB::table("leadlist")->insert([
"fname"=>$_POST["fname"],
"lname"=>$_POST["lname"],
and so on
"cskype"=>$_POST["cskype"]
]);
echo "Record inserted successfully<br>";
}
答案 1 :(得分:0)
请求中包含您的表单数据,因此您应该使用它:
$fname = $request->input('fname');
$lname = $request->input('lname');