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

时间:2019-07-04 10:59:02

标签: php html laravel

在提交用户被带到另一个页面,显示他添加的数据之后,我有提交数据的表单。

我的一些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>

当用户提交数据时,他被带到其他页面以显示他输入的内容:

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

<?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)
    {
        //
    }
}

用户被重定向到另一个页面,但是没有显示数据,请问为什么

1 个答案:

答案 0 :(得分:0)

store()方法内的注册控制器中,请添加dd(request()->all())并再次提交表单,请记住那是您根据表单操作要发布的位置。

firstname = request('firstname')