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

在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')
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥30 Hyper-v虚拟机相关问题,求解答。
  • ¥15 TSM320F2808PZA芯片 Bootloader
  • ¥45 谷歌浏览器出现开发者工具无法显示已创建的,但您可以调试已部署的代码。 状态代码 404, net::ERR HTTP RESPONSE CODE FAILURE
  • ¥15 chatgpt网页版侧边栏和模型切换点击没反应怎么办
  • ¥15 如何解决蓝牙通话音频突发失真问题
  • ¥15 安装opengauss数据库报错
  • ¥15 【急】在线问答CNC雕刻机的电子电路与编程
  • ¥60 在mc68335芯片上移植ucos ii 的成功工程文件
  • ¥15 笔记本外接显示器正常,但是笔记本屏幕黑屏
  • ¥15 Python pandas