在Laravel 5.6中注册时我遇到异常:Exception \ MethodNotAllowedHttpException没有消息

时间:2018-03-28 13:10:06

标签: laravel laravel-5 laravel-5.2 laravel-5.3 laravel-5.6

在Laravel 5.6中注册时我得到了例外:

  

Exception \ MethodNotAllowedHttpException无消息

控制器代码如下:

class ProductController extends Controller
{
    public function insertform()
    {
        return view('clientlayout.main.signup');
    }

    public function insert(Request $request)
    {
        $firstname   = $request->input('firstname');
        $lastname    = $request->input('lastname');
        $companyname = $request->input('companyname');
        $email       = $request->input('email');
        $address1    = $request->input('address1');
        $address2    = $request->input('address2');
        $city        = $request->input('city');
        $state       = $request->input('state');
        $postcode    = $request->input('postcode');
        $country     = $request->input('country');
        $phonenumber = $request->input('phonenumber');
        $password    = $request->input('password');
        $data        = [
            'firstname'   => $firstname,
            'lastname'    => $lastname,
            'city'        => $city,
            'email'       => $email,
            'country'     => $country,
            'address1'    => $address1,
            'address2'    => $address2,
            'state'       => $state,
            'postcode'    => $postcode,
            'password'    => $password,
            'phonenumber' => $phonenumber,
            'companyname' => $companyname,
        ];

        Whmcs::AddClient()->insert($data);

        echo 'Record inserted successfully.<br/>';
        echo '<a href = "/insert">Click Here</a> to go back.';
    }
}

在下面找到刀片表单并建议我一个解决方案,因为我再次得到相同的错误:&#34;方法不允许Http例外&#34;

<form class="container" action="/create" id="needs-validation" novalidate>
    <input type = "hidden" name = "_token" value = "<?php echo csrf_token(); 
?>">
      <div class="row">
        <div class="col-lg-6 col-sm-6 col-12">
           <div class="form-group">
            <label class="text-inverse custom" 
for="validationCustom01">First Name<span class="req">*</span></label>
<input type="text" name="firstname" class="form-control" 
id="validationCustom01"  placeholder="First name"
value="" required maxlength="25" onKeyPress="return ValidateAlpha(event);" 
style="background-color: rgba(19, 35, 47, 0.4); color:#fff;">
            <div class="invalid-feedback">
              Enter Your Firstname
            </div>
          </div>
        </div>
        <div class="col-lg-6 col-sm-6 col-12">
          <div class="form-group">
            <label class="text-inverse custom" for="validationCustom02">Last 
Name<span class="req">*</span></label>
            <input type="text" name="lastname" class="form-control" 
id="validationCustom02" placeholder="Last name" value="" required 
maxlength="25" onKeyPress="return ValidateAlpha(event);" style="background- 
color: rgba(19, 35, 47, 0.4); color:#fff;">
            <div class="invalid-feedback">
            Enter Your Lastname
            </div>
          </div>  
        </div>
      </div>
      <div class="row">
        <div class="col-md-6 col-sm-12 col-12">
          <div class="form-group">
            <label class="text-inverse custom" for="inputEmail4">Email<span 
class="req">*</span></label>
            <input type="email" name="email" class="form-control" 
id="inputEmail4" placeholder="Email" required maxlength="250" 
style="background-color: rgba(19, 35, 47, 0.4); color:#fff">
            <div class="invalid-feedback">
              Verify Your Email Id
            </div>
          </div>  
        </div>
        <div class="col-lg-6 col-sm-6 col-12">
          <div class="form-group">
            <label class="text-inverse custom" for="inputphone">Phone 
 Number<span class="req">*</span>
            </label>
            <input  type="tel" id="phone" name="phonenumber" class="form- 
 control"  placeholder="Phone Number" required onkeypress="return 
 isNumberKey(event)"style="background-color: rgba(19, 35, 47, 0.4); 
 color:#fff">



            <div class="invalid-feedback">
            Enter Correct Mobile Number
            </div>
          </div>  
        </div>

      </div>



      <div class="row">
        <div class="col-md-6 col-sm-12 col-12">
          <div class="form-group">
            <label class="text-inverse custom" for="inputEmail4">Address 
1<span class="req">*</span></label>
            <input type="text" name="address1" class="form-control" 
id="inputEmail4" placeholder="Address1" required style="background-color: 
rgba(19, 35, 47, 0.4); color:#fff">
            <div class="invalid-feedback">
             Enter Your Address
            </div>
          </div>  
        </div>
        <div class="col-lg-6 col-sm-6 col-12">
          <div class="form-group">
            <label class="text-inverse custom" for="inputpassword">Address 
2</label>
            <input type="text" name="address2" class="form-control" 
id="inputpassword" placeholder="Address2" style="background-color: rgba(19, 
35, 47, 0.4); color:#fff">

          </div>  
        </div>
      </div>
      <div class="row">
        <div class="col-lg-6 col-sm-6 col-12">
          <div class="form-group">
            <label class="text-inverse custom" 
for="validationCustom03">Company Name<span class="req">*</span></label>
            <input type="text" name="companyname" class="form-control" 
id="companyname" placeholder="Company Name" style="background-color: 
rgba(19, 35, 47, 0.4); color:#fff">

          </div>  
        </div>
        <div class="col-lg-6 col-sm-6 col-12">

         <div class="form-group">
            <label class="text-inverse custom" 
for="inputEmail4">Country<span class="req">*</span></label>
            <select name="country" class="custom-select d-block form-control 
countries" id="countryId" required style="background-color: rgba(19, 35, 47, 
0.4); color:#fff">
<option value="">Select Country</option>
</select>
            <div class="invalid-feedback">
             Select Your Country
            </div>
          </div>  

        </div>
      </div>
      <div class="row">
      <div class="col-md-4 col-sm-6 col-12">
          <div class="form-group">
            <label class="text-inverse custom" for="select-menu">State<span 
class="req">*</span></label>
            <select name="state" class="custom-select d-block form-control 
states" id="stateId" required style="background-color: rgba(19, 35, 47, 
0.4); color:#fff">
<option value="">Select State</option>
</select>
            <div class="invalid-feedback">
            Select Your State
            </div>
          </div>  
        </div>

        <div class="col-md-4 col-sm-12 col-12">
        <div class="form-group">
            <label class="text-inverse custom" for="select-menu">City<span 
class="req">*</span></label>

            <select name="city" class="custom-select d-block form-control 
cities" id="cityId" required style="background-color: rgba(19, 35, 47, 0.4); 
color:#fff">
<option value="">Select City</option>
</select>
            <div class="invalid-feedback">
            Select Your city
            </div>
          </div>  

        </div>

        <div class="col-md-4 col-sm-12 col-12">
          <div class="form-group">
            <label class="text-inverse custom" for="inputEmail4">Zip 
Code<span class="req">*</span></label>
            <input type="text" name="postcode" class="form-control" 
id="inputEmail4" placeholder="Zip Code" required onkeypress="return 
isNumberKey(event)" maxlength="10" style="background-color: rgba(19, 35, 47, 
0.4); color:#fff">
            <div class="invalid-feedback">
             Enter Your Correct Zip Code
            </div>
          </div>  
        </div>
      </div>

       <div class="row">
        <div class="col-md-6 col-sm-12 col-12">
          <div class="form-group">
            <label class="text-inverse custom" 
for="inputpassword">Password<span class="req">*</span></label>
            <input type="password" name="password" class="form-control" 
name="password" id="password" placeholder="Password" required="required" 
style="background-color: rgba(19, 35, 47, 0.4); color:#fff">
           <!-- <div class="invalid-feedback">
             Enter Your Password
            </div>-->

          </div>  
        </div>
        <div class="col-md-6 col-sm-12 col-12">
          <div class="form-group">
            <label class="text-inverse custom" for="inputpassword">Confirm 
Password<span class="req">*</span></label>
            <input type="password" name="password" class="form-control" 
id="confirmpassword" placeholder="Confirm Password" required="required" 
style="background-color: rgba(19, 35, 47, 0.4); color:#fff">
           <!-- <div class="invalid-feedback">
             Enter Your Confirm Password
            </div>-->
          </div>  
        </div>
      </div>

      <div class="row">

        <div class="col-lg-12 col-sm-6 col-12">
          <div class="form-group">
            <label class="custom-control custom-checkbox">
              <input type="checkbox" class="custom-control-input"  
id="inputpassword" required>

              <span class="custom-control-indicator"></span>
              <span class="custom-control-description custom"><a 
href="Terms_Service">I have read and agree to Terms and Conditions</a> 
</span>
            </label>
          </div>  
        </div>
      </div>

      <div class="row">
        <div class="col-lg-12 col-sm-12 col-12 text-center" style="padding- 
bottom: 20px;">
            <button class="btn btn-info" type="submit">Submit form</button>
        </div>
      </div>  
    </form>

找到我的控制器表单,刀片表单,视图和路由表单的编码,并给我一个解决方案来解决这个问题&#34;方法不允许Http Exception&#34;。

2 个答案:

答案 0 :(得分:1)

MethodNotAllowedHttpException ..请检查POST或GET ..

顺便说一句

太多了。您使用相同的变量作为列名,然后就像下面的质量分配一样。

SELECT a.id
  FROM table1 a
  where a.ind IS NULL
    and (   exists (select null from table2 b
                      WHERE a.id = b.id
                        AND b.year >= '2017'
                        AND b.code IN ('01','02','03')
                        AND b.flag NOT IN ('F','L') )
         or exists (SELECT null FROM table3 c
                      WHERE a.id = c.id
                        AND c.area = 'MAIN'
                        AND SYSDATE >= c.startdt)
        )

答案 1 :(得分:0)

检查您的路线,您在路线中使用了错误的方法。例如,您可以发送表单,但路线方法是