douquan3294
2019-07-04 10:59
浏览 133
已采纳

在laravel php中提交后,表单数据未显示

i have form for submitting data, after submission user is taken to another page displaying the data he added.

some of my html:

  <form id=""  method="POST" enctype="multipart/form-data"  action="{{ route('register.store') }}">
                    @csrf

                    <input id="website" name="website" type="text" value="">
                    <!-- Leave for security protection, read docs for details -->
                    <div id="middle-wizard">
                        <div class="step">

                            <!-- <h3 class="main_question"><strong>1/5</strong>Primary Applicant Name</h3> -->
                            <label>Applicant Name</label>
                            <div class="form-group">
                                <input type="text" name="firstname" class="form-control required" placeholder="First Name">
                            </div>
                            <div class="form-group">
                                <input type="text" name="lastname" class="form-control required" placeholder="Last Name">
                            </div>

when the user submits data he is taken to different page to display what he entered:

<h5>Name:&nbsp;<?php if(isset($_POST['firstname'])){echo $_POST["firstname"];}; ?></h5>
controller

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\Register;
use App\Mail\SendEmail;
use Session;
use Mail;
use Storage;
use Illuminate\Support\Facades\File;

class RegController extends Controller
{

    public function index()
    {
        //
    }


    public function create()
    {
        //
    }

    public function store(Request $request)
    {

       // return $request;


// return $request->Fee;
            $data = new Register;
            $data->firstname = $request->firstname;
            $data->lastname = $request->lastname;
            $data->mobilenumber = $request->mobilenumber;
            $data->experience = $request->experience;
            $data->designation = $request->designation;
            $data->confirmation = $request->confirmation;
            $data->company = $request->company;
            $data->address = $request->address;
            $data->addressline2 = $request->addressline2;
            $data->city = $request->city;
            $data->state = $request->state;
            $data->pin = $request->pin;
            $data->country = $request->country;
            $data->Whatsapp = $request->Whatsapp;
            $data->alternatenumber = $request->alternatenumber;
            $data->Email = $request->Email;
            $data->CompanyRegNumber = $request->CompanyRegNumber;
            $data->Date_Incorporation_orBusi_Stp = $request->Date_Incorporation_orBusi_Stp;
            $data->GSTIN = $request->GSTIN;
            $data->Services_Offered = $request->Services_Offered;
            $data->Annual_Turnover = $request->Annual_Turnover;
            $data->Declaration = $request->Declaration;

            $data->termsandconditions = $request->termsandconditions;
            // $data->Fee = $request->Fee;
            $data->Mode_of_Payment = $request->Mode_of_Payment;

            $data->Recommended_by_A = $request->Recommended_by_A;
            $data->Recommended_by_B = $request->Recommended_by_B;

              $fee = $request->Fee[0];
              $data->Fee = $fee;

              if(!empty($request->Fee[1]))
              {
               $data->Fee1 = $request->Fee[1];
              }
              if(!empty($request->Fee[2]))
              {
               $data->Fee2 = $request->Fee[2];
              }
            if(!empty($request->Fee[3]))
              {
               $data->Fee3 = $request->Fee[3];
              }


 if($request->hasFile('Photo')) {
      $image = $request->file('Photo');
      $filename = time().$image->getClientOriginalName();
      $destinationPath = public_path('uploads/Photo');

     Storage::disk('public')->put($filename,  File::get($image));
      $data->Photo=$filename;
    }
 if($request->hasFile('Receipt')) {
      $image = $request->file('Receipt');
      $filename = time().$image->getClientOriginalName();
      $destinationPath = public_path('uploads/Receipt');
    Storage::disk('public')->put($filename,  File::get($image));
      $data->Receipt=$filename;
    }
 if($request->hasFile('Signature')) {
      $image = $request->file('Signature');
      $filename = time().$image->getClientOriginalName();
      $destinationPath = public_path('uploads/Signature');
      Storage::disk('public')->put($filename,  File::get($image));
      $data->Signature=$filename;
    }

            $data->save();
            Session::flash('registered','reg');


        $name = $request->firstname." ".$request->lastname;
        $subject = "TEIA";
        $message =  $data->id;

         $photo = $data->Photo;
         $sign = $data->Signature;
         $recipt= $data->Receipt;
         $email = 'zubairnazeroliyat@gmail.com';
    


        // ->cc(['name1@domain.com','name2@domain.com'])
      Mail::to($email)->send( new SendEmail($subject,$message , $photo ,$sign,$recipt));




            return redirect('demo')->with(['reg'=>$data]);
    }


    public function show($id)
    {
        //
    }


    public function edit($id)
    {
        //
    }


    public function update(Request $request, $id)
    {
        //
    }


    public function destroy($id)
    {
        //
    }
}

the user is redirected to another page,but the data is not being displayed, may i know why

</div>
  • 写回答
  • 好问题 提建议
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • douyue4334 2019-07-04 11:03
    已采纳

    In your register controller inside store() method please add dd(request()->all()) and submit the form again, remember thats where your are posting according to your form action.

    firstname = request('firstname')
    
    已采纳该答案
    评论
    解决 无用
    打赏 举报

相关推荐 更多相似问题