2017-10-04 51 views
1

當我試圖發佈數據時,我得到了像未定義變量多次相同的錯誤。我不知道錯誤在哪裏,甚至數據也沒有發佈到數據庫中。我希望你能幫助解決這個錯誤。如果有修改請告訴我。發佈數據到服務器時出錯

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','[email protected]'); 
Route::post('create','[email protected]'); 

output

在此先感謝您的幫助。

回答

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>"; 
    } 
0
  1. 您應該使用模型從數據庫插入/更新/刪除數據。
  2. 請求包含表單數據,因此你應該使用它:

    $fname = $request->input('fname'); 
    $lname = $request->input('lname'); 
    
+0

嗨,感謝您的回覆。我可以如何讓插入/更新/刪除模型,請你幫我 – Hemanth