Welcome Guest, Not a member yet? Register   Sign In
Problem with submit a form and redirect
#1

Hi,

this is the controller function with some simplified code:

PHP Code:
public function index() {
  return 
view('layout', ['contactform' => $this->getContactform]);
}


public function 
getContactform() {
   
  if (
$this->form_validation->withRequest($this->request)->run(NULL'contact') === true) {
    return 
redirect(current_url());
  } 

  return 
view('form');


In my template:
PHP Code:
echo $contactform// Object of class CodeIgniter\HTTP\RedirectResponse could not be converted to string 

I know the reason, but how can i fix this? If the form is valid i want to make a redirect but in this case the variable in the template is an object and not the view. This is the error message:
Object of class CodeIgniter\HTTP\RedirectResponse could not be converted to string
Reply




Theme © iAndrew 2016 - Forum software by © MyBB