Welcome Guest, Not a member yet? Register   Sign In
Problem with form submit
#1

[eluser]stingray9[/eluser]
For an unkown reason my form don't want to submit..
It just puts it's values into my url..

This is my view:
Code:
<form method="post" action="admin.php">
                            
                <label>Kleur titel:</label>
                &lt;?php echo '<span style="font-size:12px;">' . form_error('kleurtitel') . '</span>'; ?&gt;
                &lt;input value="&lt;?php echo set_value('kleurtitel'); ?&gt;" id="kleurtitel" size='6' name="kleurtitel"&gt;&lt;br />
                       &lt;input type="submit" name="save" id="save" value="Save"&gt;

&lt;/form&gt;


And this is my controller:
Code:
function Admin()
    {
        parent::Controller();    
    }
    
    function index()
    {
        
        $this->load->helper('form', 'url');
             $this->load->library('form_validation');

            $rules = array(
            
                array(
                    'field' => 'kleurtitel',
                    'rules' => 'required|xss_clean'
                )
            );
            
              $this->form_validation->set_rules($rules);
            
                if ($this->form_validation->run()) {

                    $kleurtitel = $this->input->post('kleurtitel');
            
                $insert = array(
                        'color' => $kleurtitel
                        );

                $this->db->where('type', 'title');
                $this->db->update('design', $insert);
                
                   $this->load->view('header', $data);
                $this->load->view('welcome_message', $data);
                $this->load->view('footer', $data);
                }
                else{
                $this->load->view('header', $data);
                $this->load->view('admin_view', $data);
                $this->load->view('footer', $data);
                }
    
    }

And my base_url is set correct with the http://...
I've done many forms and never faced this problem.
The fact is that when i click on 'save', it put's my values in my url: /admin?kleurtitel=323232&save=Save
But nothing happens.. If i put an alert after if ($this->form_validation->run()) { nothing appears, so it doesn't work..

Anyone have an idea what i'm missing here?
#2

[eluser]stingray9[/eluser]
Maybe something in a config file or something, i don't have a clue..

Anyone has an idea?
#3

[eluser]bogdan3l[/eluser]
Hello!

Do you use mod_rewrite? If you do please follow this steps:

1. Change $this->load->helper('form', 'url'); to $this->load->helper(array('form', 'url'));
2. Change action="admin.php" to action="&lt;?php echo base_url(); ?&gt;admin/"

Than everything will work just fine.

If you do not use mod_rewrite I recommend you to read this guide first http://farinspace.com/codeigniter-htaccess-file/

Bye
#4

[eluser]stingray9[/eluser]
[quote author="ci_the_best" date="1297029770"]Hello!

Do you use mod_rewrite? If you do please follow this steps:

1. Change $this->load->helper('form', 'url'); to $this->load->helper(array('form', 'url'));
2. Change action="admin.php" to action="&lt;?php echo base_url(); ?&gt;admin/"

Than everything will work just fine.

If you do not use mod_rewrite I recommend you to read this guide first http://farinspace.com/codeigniter-htaccess-file/

Bye[/quote]

Hey,

Thanks for your reply. Indeed, i use mod_rewrite.
I changed the things you said, but still the same problem.

From http://site.assist/admin where my form is, after submitting i stay on the same page, but the url changes to: http://site.assist/admin?kleurtitel=323232&save=Save

I really don't understand the problem..
I hope anyone knows a solution.
#5

[eluser]bogdan3l[/eluser]
It is really weird.

I get this kind of url http://site.assist/admin?kleurtitel=323232&save=Save only when i change method="post" to method="get".
#6

[eluser]stingray9[/eluser]
[quote author="ci_the_best" date="1297031125"]It is really weird.

I get this kind of url http://site.assist/admin?kleurtitel=323232&save=Save only when i change method="post" to method="get".[/quote]

Yeah, i think that must me the problem. That's why i wrote &lt;form method="post" action="admin.php"&gt; in stead of form_open() already, but didn't seem to help.

Can it be defined in a config file or something maybe?
#7

[eluser]bogdan3l[/eluser]
Can you attach your config.php file?
#8

[eluser]stingray9[/eluser]
Code:
&lt;?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');

$config['base_url']    = "http://site.assist/";

$config['index_page'] = "";

$config['uri_protocol']    = "PATH_INFO";

$config['url_suffix'] = "";

$config['language']    = "english";

$config['charset'] = "UTF-8";

$config['enable_hooks'] = FALSE;

$config['subclass_prefix'] = 'MY_';

$config['permitted_uri_chars'] = 'a-z 0-9~%.:_\-';

$config['enable_query_strings'] = TRUE;
$config['controller_trigger']     = 'c';
$config['function_trigger']     = 'm';
$config['directory_trigger']     = 'd'; // experimental not currently in use

$config['log_threshold'] = 0;

$config['log_path'] = '';

$config['log_date_format'] = 'Y-m-d H:i:s';

$config['cache_path'] = '';

$config['encryption_key'] = "";

$config['sess_cookie_name']        = 'ci_session';
$config['sess_expiration']        = 7200;
$config['sess_encrypt_cookie']    = FALSE;
$config['sess_use_database']    = FALSE;
$config['sess_table_name']        = 'ci_sessions';
$config['sess_match_ip']        = FALSE;
$config['sess_match_useragent']    = TRUE;
$config['sess_time_to_update']     = 300;
$config['cookie_prefix']    = "";
$config['cookie_domain']    = "";
$config['cookie_path']        = "/";
$config['global_xss_filtering'] = FALSE;
$config['compress_output'] = FALSE;
$config['time_reference'] = 'local';
$config['rewrite_short_tags'] = FALSE;
#9

[eluser]bogdan3l[/eluser]
Everything works fine for me with your configuration.
#10

[eluser]stingray9[/eluser]
This is damn strange, i tried to write another form with other validations, but it doesn't work. It must be because of a file somewhere else Confused




Theme © iAndrew 2016 - Forum software by © MyBB