Mehur Mehur - 1 month ago 6
PHP Question

How to get posted value from different function?

I am using codeigniter 3.1 .

How to return or get posted email after submit data from different function?

HTML



<form action="settings/valid" class="form-horizontal" enctype="multipart/form-data" method="post" accept-charset="utf-8">
<input type="email" name="email" value="<?php echo $email ?>" />
<input type="submit"/>
</form>


PHP

public function index() {
// how to get post email ?
$email = $this->input->post("email"));

$this->template->loadContent("settings/index.php", array(
"email" => $email
)
);

}

public function valid() {
$email = $this->input->post("email"));

$this->user->add($this->user->ID, array(
"email" => $email
));

redirect(site_url("index.php"));

}

Answer

This may answer your question better.

public function index() {
    // how to get post email ? 
   $email = $this->session->flashdata("email");

   $this->template->loadContent("settings/index.php", array(
    "email" => $email
    )
    );

}

public function valid() {
    $email = $this->input->post("email"));

    $this->user->add($this->user->ID, array(
        "email" => $email
    ));

    $this->session->set_flashdata("email",$email);

    redirect(site_url("index.php"));

}
Comments