PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Monday, April 18, 2022

[FIXED] how to return to a specific page after form submit based on value laravel

 April 18, 2022     forms, laravel, return     No comments   

Issue

i have a logic whereby on form submission i want to return to specific page based on a certain value the user choosed when submiting the form.the form works well but when i try to return it doesnt work.where might i be missing the point here.

 public function addtoorder(Request $request){
    $userid=Auth::user()->id;
     $addresses=Deliveryaddress::where('user_id',$userid)->first();
      if($request->isMethod('post')){
        $data=$request->all();
        $order = new Order();
        $order->name = Auth::user()->name;
        $order->phone =$addresses->phone;
        $order->county =$addresses->shipcharges->county;
        $order->town =$addresses->towns->town;
        $order->order_status="New Order";
        $order->payment_method = $request->payment_method;
        $order->user_id =$userid;
        $order->grand_total = Session::get('grand_total');
        $order->shipping_charges=$addresses->shipping_cost;
        $order->save();
        }
       if($data=="SKRILL"){
            return view('frontend.product.skrill');
        }elseif($data=="PAYPAL"){
            return view('frontend.product.paypal');
        }
     } 
  }

i have been able to save the data on the database but am unable to return to the specific pages.rather it return to blank page without any error,but it saves the data to the orders table perfectly.


Solution

I guess blank screen means that nothing was returned, because you are trying to check whether $data(which is array) is equal to some string. My thoughts would be for you to try check string in your if statement. Like this

  if($data['payment_method'] === "SKRILL"){
            return view('frontend.product.skrill');
        }elseif(data['payment_method'] === "PAYPAL"){
            return view('frontend.product.paypal');
        }



Answered By - goose
Answer Checked By - David Marino (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing