Welcome Guest, Not a member yet? Register   Sign In
redirect won't work
#1

[eluser]CI_[/eluser]
my redirect() won't fire... please check my codes...

the problem is when I click submit button it goes to another url like sooo

"http://localhost/code_igniter/index.php/blog/index.php/blog/index" as you can see the

URI has been repeated. what did I do wrong here..

Thank you in advance...


Code:
<?Php

    class Blog extends Controller {
    
        function Blog()
        {
            parent::Controller();

            $this->load->helper('url');
            $this->load->helper('form');
        }
    
        function index()
        {

            $data['title'] = 'My Sample Tutorial';
            $data['heading'] = 'This is my Heading';
        
      
            $data['view_data'] = $this->db->get('tblniel');
            
      
            $this->load->view('view_blog', $data);    
        }

        function insert_data()
        {
            $this->db->insert('tblniel',$_POST);
            redirect('blog/index');
        }
}
?>
#2

[eluser]bugboy[/eluser]
in your form part have you got it pointing to blog/insert_data?
#3

[eluser]CI_[/eluser]
yep, here's my form code

Code:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title><?php echo $title; ?></title>
</head>
<body>

<h2>&lt;?php echo $heading; ?&gt;</h4>

&lt;?php foreach($view_data->result() as $row): ?&gt;

&lt;?php echo $row->id, '.'; ?&gt;

<font size="+1">&lt;?php echo $row->name; ?&gt;</font>
<br />&lt;?php echo $row->email; ?&gt;
<br />&lt;?php echo $row->message; ?&gt;

<hr />

&lt;?php endforeach ?&gt;

&lt;?php echo form_open('blog/insert_data/'); ?&gt;

&lt;input name="name" type="text"&gt;
<p />
&lt;input name="email" type="text"&gt;
<p />
&lt;textarea name="message" cols="15" rows="6" wrap="soft"&gt;&lt;/textarea&gt;
<p />
&lt;input name="author" type="test"&gt;
<p />
&lt;input type="submit" value="Submit"&gt;

&lt;/form&gt;
&lt;/body&gt;
&lt;/html&gt;
#4

[eluser]CI_[/eluser]
I used the header('location') function and it work's fine, But I want to do it in a CI way...
#5

[eluser]NemetraL[/eluser]
What about the index.php in the URL?




Theme © iAndrew 2016 - Forum software by © MyBB