Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
533 views
in Technique[技术] by (71.8m points)

not able get post form submit values in codeigniter

I tried a simple form submit But I am not able to get the form values on controller using $this->input->post as well as $_POST[] methods. My view part is

<html>
<head>
    <title> Feedback page</title>       
</head>
<body>

    <?php echo form_open('feedback/save'); ?>       
    <p>
        <label>name: </label>
        <?php echo form_input('name'); ?>

    </p>
    <p>
    <label>Email: </label>
        <?php echo form_input('email'); ?>
    </p>
    <p>
    <label>Feedback: </label>
        <?php echo form_textarea('feedback'); ?>
    </p>
    <p>
        <?php echo form_submit('submit','Submit'); ?>
    </p>

    <?php echo form_close(); ?>

</body> 

</html>

and controller part is

<?php
class Feedback extends CI_Controller {

function __construct() {
    parent::__construct();      
    $this->load->model("MFeedback");

}
function index() {

    $this->load->view('home/feedback_view.php');
    //print "loaded";


}

function save() {
    print "called";     
    print_r($this->input); 
    $name = $this->input->post('uname');
    $email = $this->input->post('email');
    $feedback = $this->input->post('feedback');
    print $name . $email . $feedback;
    $this->index();
}

}
?>

I am not sure what went wrong here or is there any config settings I need to look in to it.?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I have found out the problem. It is actually with the rewrite rule. Make sure you have rewrite rule like

RewriteEngine On
RewriteRule ^(application) - [F,L] 
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]

on root folder of codeigniter.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...