简体   繁体   中英

issue with form_open codeigniter 3

I have a strange issue with the codeigniter form_open function.

When I pass this code:

<?php echo form_open('login/check');?>

It actually prints out this

<form action="http://***.***.***.***/***/index.php/login" method="post" accept-charset="<meta charset="utf-8">">

The error is exactly at the end of the form open tag. Where is located the accept-charset attribute. Besides the fact that I do not need the accept-charset attribute, since I've declared the meta in the head, it's printing it in a wrong format!

accept-charset="<meta charset="utf-8">">

This code outputs on the page the form and the double quotes and the angular closing.

">

The real problem it's not the accept-charset attribute itself but the wrong printing of it. Instead of accept-charset="utf-8" it pulls in the meta tag of the charset

What's happening? I can't figure this out... Thank you all!

Please check the documentation of Codeigniter http://www.codeigniter.com/user_guide/helpers/form_helper.html . It says that if you are using form_open() then it creates an opening form tag with a base URL built from your config preferences. It will optionally let you add form attributes and hidden input fields, and .

Also try this it should works as it will not override if already defined in the attributes.

$attributes = array(
     'accept-charset'=>'utf8'
);
echo form_open('login/check', $attributes);

Make sure that you have configured base_url in config.php file

$config['base_url'] = 'http://localhost/project'; //your project location

and also load form helper in controller

$this->load->helper('form');

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM