Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
553 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 Reply

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...