Welcome Guest, Not a member yet? Register   Sign In
n00b - open_form() won't work! What am I overlooking?
#1

[eluser]stormbytes[/eluser]
Well.. Finally getting into the CI-swing-of-things but for some odd reason I can't get my form_open() (or any other form helpers) to work.

This is a sample project so nothing complex Smile

Here's the View:
Code:
<!DOCTYPE html>

&lt;html&gt;
&lt;head&gt;
  &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8"&gt;
  &lt;title&gt;&lt;?=$title?&gt;&lt;/title&gt;
&lt;/head&gt;
&lt;body id="&lt;?=$css['css_body_id'];?&gt;"&gt;
  <h1>&lt;?=$heading?&gt;</h1>
  &lt;?php form_open('control/auth'); ?&gt;
  &lt;?php form_input('Login'); ?&gt;
  &lt;/form&gt;

&lt;/body&gt;
&lt;/html&gt;

And the controller...
Code:
&lt;?php

if (! defined('BASEPATH')) exit('No direct script access');

class Control extends Controller {

    function __construct() {
      
        parent::Controller();
        
        // Added to Autoload array
        // $this->load->helper('url');
        // $this->load->helper('form');
    }
    
    function index() {
        
        // Display Variables
        $data["title"] = "Login Screen";
        $data["heading"] = "Please Login!";
        
        $data["css"] = array(
                                'css_body_id' => 'body_login'
                            );
                
        $this->load->view('login', $data);
    }
}




/* End of file Start.php */
/*
#2

[eluser]prince1001[/eluser]
What is the error?

Maybe you must include base_url()?
Code:
&lt;?php form_open(base_url().'control/auth'); ?&gt;
&lt;?php form_input('Login'); ?&gt;
&lt;?php form_close(); ?&gt;
#3

[eluser]stormbytes[/eluser]
[quote author="prince1001" date="1286090125"]What is the error?

Maybe you must include base_url()?
Code:
&lt;?php form_open(base_url().'control/auth'); ?&gt;
&lt;?php form_input('Login'); ?&gt;
&lt;?php form_close(); ?&gt;
[/quote]

That's just it - there is NO error!

If there was, actually that'd be helpful. The page resolves just fine by the form functions aren't being executed.

I doubt I need to put in the base URL. It's already been entered in config and the classes/views are resolving just fine.

What's super weird about this is that just yesterday I followed the "Blog" tutorial on CI and it worked just fine. I doing this - I pretty much retraced my steps.
#4

[eluser]Rob @ iFetch[/eluser]
You need to echo the form_* functions.

I.e. Change
Code:
&lt;?php form_open('control/auth'); ?&gt;
  &lt;?php form_input('Login'); ?&gt;
to
Code:
&lt;?php echo form_open('control/auth'); ?&gt;
  &lt;?php echo form_input('Login'); ?&gt;
or
Code:
&lt;?=form_open('control/auth'); ?&gt;
  &lt;?=form_input('Login'); ?&gt;
#5

[eluser]stormbytes[/eluser]
[quote author="robfromnewy" date="1286091160"]You need to echo the form_* functions.

I.e. Change
Code:
&lt;?php form_open('control/auth'); ?&gt;
  &lt;?php form_input('Login'); ?&gt;
to
Code:
&lt;?php echo form_open('control/auth'); ?&gt;
  &lt;?php echo form_input('Login'); ?&gt;
or
Code:
&lt;?=form_open('control/auth'); ?&gt;
  &lt;?=form_input('Login'); ?&gt;
[/quote]

I just went (back) to check the user guide -

It's official: I'm blind!

Thanks for pointing out the error man...




Theme © iAndrew 2016 - Forum software by © MyBB