jeudi 29 mars 2018

While Registering in Laravel 5.6 I'm getting exception: Exception \ MethodNotAllowedHttpException No message

While Registering in Laravel 5.6 I'm getting exception:

Exception \ MethodNotAllowedHttpException No message

The Controller code is given below:

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.';
    }
}

Find below the blade form and suggest me a solution as I'm getting the same error again as : "Method Not Allowed Http Exception"

<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>

Find the coding of my controller form, blade form, view and route form and give me a solution to solve this "Method not allowed Http Exception".



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2GAAfDT
via IFTTT

Aucun commentaire:

Enregistrer un commentaire