[英]Issue in using checkbox in sign up form in Codeigniter
My sign up form was previously working well. 我的注册表单以前运行良好。 However, I had to add an acceptance page or terms and conditions before sign up can be successful.
但是,我必须添加接受页面或条款和条件才能成功注册。 I thought it would be better to include it in sign up page rather than after sign up (before being presented with member's homepage).
我认为最好将其包含在注册页面中,而不要在注册后添加(在出现成员主页之前)。 Problem is, it's having a lot of issues.
问题是,它有很多问题。 It's not working properly.
它无法正常工作。
Here's my code in view page: (i added this at the bottom of all fields before sign up button) 这是我在查看页面中的代码:(我在注册按钮之前将其添加到所有字段的底部)
Please proceed only if you accept our <a target="blank" href="<?php site_url("in/terms_and_conditions");?>">terms and conditions</a>.
<input type='checkbox' name='terms' value='checked' id='terms' required autofocus/><br/>
Right now, it seems to work fine (codeigniter built in validation prompts up a message telling the user to click before he can proceed). 现在,它似乎可以正常工作(内置于验证中的codeigniter会提示用户单击,然后继续操作)。 Issue is 1. the link ("in/terms_and_conditions") does not show properly.
问题是1.链接(“ in / terms_and_conditions”)显示不正确。 Whenever the corresponding text is clicked, instead of showing the proper page, it just opens up a new sign up page.
每当单击相应的文本时,它不会打开相应的页面,而是打开一个新的注册页面。 Second issue is the presence of errors as follows: Message: Undefined index: c_terms in model Line Number: 24 Line 24 is this:
第二个问题是存在错误,如下所示:消息:未定义索引:模型中的c_terms行号:24行24是:
'terms'=> $post_obj['c_terms']
I tried to add this to my array. 我试图将其添加到我的阵列。 Was it actually correct?
真的正确吗? The second error shown is:
显示的第二个错误是:
Column 'terms' cannot be null 列“ terms”不能为空
INSERT INTO `client` (`first_name`, `last_name`, `email_address`, `password`, `address`, `tagline`, `profile`, `interests`, `billing_mode`, `terms`) VALUES ('dsfhkds', 'hfdskhflk', 'test@yahoo.com', '123456', 'fsdkfhsdk', 'sdkfhsdkf', 'sdklhfslkdhflsdhf', 'kdslhflks', 'Escrow', NULL)
What I did to my original table is I added column which I named "terms", set it to text type and no default value. 我对原始表所做的是添加了一个名为“ terms”的列,将其设置为文本类型,没有默认值。
Please help me fix this. 请帮我解决这个问题。
Thanks! 谢谢!
Issue 1: Did you create the page "in/terms_and_conditions" ? 问题1:您是否创建了“ in / terms_and_conditions”页面? make sure?
确保?
Controller Name: in 控制器名称:in
Action Name : terms_and_conditions 动作名称:terms_and_conditions
Issue 2: You have named checkbox as "terms". 问题2:您已将复选框命名为“ terms”。 then, you should get the posted value as follows
然后,您应该获得如下的过帐值
'terms'=> $post_obj['terms']
Issue 3: Set "terms" column default value as "NULL" 问题3:将“条款”列的默认值设置为“ NULL”
I see three problems: 我看到三个问题:
You're not echoing the result of the site_url
function. 您没有回显
site_url
函数的结果。 Just put echo
in front of it. 只需在其前面放置
echo
。
If $post_obj
is your '$_POST array you have to use the
name` attribute of the HTML input as the key: 如果
$post_obj
是您的$ _POST array you have to use the
HTML输入array you have to use the
name属性作为键:
'terms' => $post_obj['terms']
Your problem is that you're not setting any text to be saved in terms
. 您的问题是您没有设置要以
terms
保存的任何文本。 Add it to the second parameter of $this->db->insert('table', $data)
like this: $data['terms'] = '...'
像这样将其添加到
$this->db->insert('table', $data)
的第二个参数中: $data['terms'] = '...'
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.