简体   繁体   English

使用PHP注册表格中的单选按钮同意或不同意条款和条件

[英]Using radio buttons in PHP registration form to agree or disagree to Terms and Conditions

I've searched for this answer and cannot find it. 我已经搜索了这个答案,但找不到它。 If you can point me to it, I will look at it. 如果您能指出我的意思,我会看的。 I'm working in Dreamweaver and fairly new to PHP and MySQL etc. My issue is: I have a simple PHP registration form for visitors to fill out (email, username, password and radio buttons for "Agree to terms" or "Disagree") so they can log into my site and view content. 我在Dreamweaver中工作,并且对PHP和MySQL等还很陌生。我的问题是:我有一个简单的PHP注册表单,供访客填写(电子邮件,用户名,密码和单选按钮,表示“同意条款”或“不同意” ),以便他们可以登录我的网站并查看内容。 All works fine except I want visitors to click on "Agree to terms", otherwise it will not let them in. As of now, I can still create new accounts (in my testing) regardless of leaving the selection on disagree. 除了我希望访问者单击“同意条款”之外,其他所有方法都工作正常,到目前为止,无论选择是否同意,我仍然可以创建新帐户(在我的测试中)(在测试中)。 I have seen answers using JavaScript but is there an answer in PHP? 我已经看到使用JavaScript的答案,但是PHP中有答案吗? Here is that portion of the form if it helps. 如果有帮助,这是表格的该部分。 Thank you in advance. 先感谢您。

 <label> <input name="AgreeDisagree" type="radio" required id="AgreeDisagree_0" form="register"> I agree to the <a href="agreement.html">Terms and Conditions</a></label> <br> <br> <label> <input name="AgreeDisagree" type="radio" id="AgreeDisagree" value="radio" checked="checked"> I disagree.</label> 

您需要将每个单选字段中的值分别设置为“同意”和“不同意”(不是“ radio”),然后让后端代码确保$_POST['AgreeDisagree'] == "agree"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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