CodeIgniter Forums

Full Version: CodeIgniter User Guide Version 1.7.2 not working
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

[eluser]explores[/eluser]
Hi,
I am trying learn how to setup a form to do simple validation. I am following the CodeIgniter User Guide Version 1.7.2 (http://ellislab.com/codeigniter/user-gui...erview)and its just not working. I even copied the views and controller directly from the tutorial but when I hit the submit button it refreshes. Its not showing errors and when everything is filled out it doesn't go to the success page. I am new to CI and could be doing something wrong, but I just don't see it.

Thanks

Code:
<?php

class Form extends Controller {
    
    function index()
    {
        $this->load->helper(array('form', 'url'));
        
        $this->load->library('form_validation');
            
        $this->form_validation->set_rules('username', 'Username', 'required');
        $this->form_validation->set_rules('password', 'Password', 'required');
        $this->form_validation->set_rules('passconf', 'Password Confirmation', 'required');
        $this->form_validation->set_rules('email', 'Email', 'required');
            
        if ($this->form_validation->run() == FALSE)
        {
            $this->load->view('myform');
        }
        else
        {
            $this->load->view('formsuccess');
        }
    }
}
?>

Code:
<html>
<head>
<title>My Form</title>
</head>
<body>
<?php echo validation_errors(); ?>

<?php echo form_open('form'); ?>

<h5>Username</h5>
&lt;input type="text" name="username" value="" size="50" /&gt;

<h5>Password</h5>
&lt;input type="text" name="password" value="" size="50" /&gt;

<h5>Password Confirm</h5>
&lt;input type="text" name="passconf" value="" size="50" /&gt;

<h5>Email Address</h5>
&lt;input type="text" name="email" value="" size="50" /&gt;

<div>&lt;input type="submit" value="Submit" /&gt;&lt;/div>

&lt;/form&gt;

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

El Forum

[eluser]explores[/eluser]
I figured it out.

My base_url was going to "http://domain.com" but I have my domain set to redirect to "http://www.domain.com". So when the form was submitting is was going to the domain without the "www". Once I changed the base_url with the "www" it worked.

El Forum

[eluser]katimari[/eluser]
Summer - I had the exact same problem and your solution worked for me - thanks for posting it!