我一直在尝试将某个表单中包含的一些信息发布给自己。但我不明白为什么它不起作用。当我从 HTML 页面发布数据时它有效,但是当我将信息发布到自身时它不起作用。
代码如下:
$country = isset($_POST['country']) ? $_POST['country'] : 'Belize';
$number_of_guests = isset($_POST['number_of_guests']) ? $_POST['number_of_guests'] : 2;
$from = isset($_POST['price_range_from']) ? $_POST['price_range_from'] : 200;
$to = isset($_POST['price_range_to']) ? $_POST['price_range_to'] : 2000;
当我从 HTML 表单发布信息时,它工作正常,但在提交给它自己时,所有变量都包含“on”的值。我不知道我遗漏了什么或未能正确实现。
这是 HTML 表单代码:
<form action="find_results.php" method = "post">
<strong>Select the Country</strong><br />
<input id = 'c1' type= "radio" name= "country" checked/> Mexico <br />
<input id = 'c2' type= "radio" name= "country" /> Belize <br />
<input id = 'c3' type = "radio" name= "country" />Jamaica <br />
<input id = 'c4' type = "radio" name= "country" />Thailand <br />
<input id = 'c5' type = "radio" name= "country" />Turks & Caicos
<hr />
<strong>Number of Guests</strong><br />
<input id = 'n1' type= "radio" name= "number_of_guests" /> 2
<input id = 'n2' type= "radio" name= "number_of_guests" /> 4
<input id = 'n3' type= "radio" name= "number_of_guests" /> 6
<input id = 'n4' type= "radio" name= "number_of_guests" /> 8
<input id = 'n5' type= "radio" name= "number_of_guests" /> 10+
<hr />
<strong>Price Range(From)</strong><br />
<input id = 'from1' type= "radio" name= "price_range_from" /> 200
<input id = 'from2' type= "radio" name= "price_range_from" /> 300
<input id = 'from3' type= "radio" name= "price_range_from" /> 400
<input id = 'from4' type= "radio" name= "price_range_from" /> 500
<input id = 'from5' type= "radio" name= "price_range_from" /> 600 or More
<hr />
<strong>Price Range(Upto)</strong><br />
<input id = 'to1' type= "radio" name= "price_range_to" /> 500
<input id = 'to2' type= "radio" name= "price_range_to" /> 600
<input id = 'to3' type= "radio" name= "price_range_to" /> 700
<input id = 'to4' type= "radio" name= "price_range_to" /> 800
<input id = 'to5' type= "radio" name= "price_range_to" /> 900 or More
<br />
<input type="submit" value="Submit" name='submit' />
</form>
最佳答案
您没有在表单中设置任何值。当指向另一个页面时,如何工作?
<input id = 'c1' type= "radio" name= "country" checked value='mexico' />
您确实需要在表单中设置一个 value='something' 以便传递正确的数据。您可能在传递表单元素时将它们设置为“打开”,但在它的 value 中没有任何信息。
关于PHP 表单发布到自身,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12024071/
我得到了一个包含嵌套链接的表单。编辑时链接字段为空的问题。这是我的表格:Editingkategori{:action=>'update',:id=>@konkurrancer.id})do|f|%>'Trackingurl',:style=>'width:500;'%>'Editkonkurrence'%>|我的konkurrencer模型:has_one:link我的链接模型:classLink我的konkurrancer编辑操作:defedit@konkurrancer=Konkurrancer.find(params[:id])@konkurrancer.link_attrib
我有一个服务模型/表及其注册表。在表单中,我几乎拥有服务的所有字段,但我想在验证服务对象之前自动设置其中一些值。示例:--服务Controller#创建Action:defcreate@service=Service.new@service_form=ServiceFormObject.new(@service)@service_form.validate(params[:service_form_object])and@service_form.saverespond_with(@service_form,location:admin_services_path)end在验证@ser
无论您是想搭建桌面端、WEB端或者移动端APP应用,HOOPSPlatform组件都可以为您提供弹性的3D集成架构,同时,由工业领域3D技术专家组成的HOOPS技术团队也能为您提供技术支持服务。如果您的客户期望有一种在多个平台(桌面/WEB/APP,而且某些客户端是“瘦”客户端)快速、方便地将数据接入到3D应用系统的解决方案,并且当访问数据时,在各个平台上的性能和用户体验保持一致,HOOPSPlatform将帮助您完成。利用HOOPSPlatform,您可以开发在任何环境下的3D基础应用架构。HOOPSPlatform可以帮您打造3D创新型产品,HOOPSSDK包含的技术有:快速且准确的CAD
有人知道在发布新版本的Ruby和Rails时收到电子邮件的方法吗?他们有邮件列表,RubyonRails有一个推特,但我不想听到那些随之而来的喧嚣,我只想知道什么时候发布新版本,尤其是那些有安全修复的版本。 最佳答案 从therailsblog获取提要.http://weblog.rubyonrails.org/feed/atom.xml 关于ruby-on-rails-如何在发布新的Ruby或Rails版本时收到通知?,我们在StackOverflow上找到一个类似的问题:
我在事件管理员编辑页面中有嵌套资源,但我只想允许管理员编辑现有资源的内容,而不是添加新的嵌套资源。我的代码看起来像这样:formdo|f|f.inputsdof.input:authorf.input:contentf.has_many:commentsdo|comment_form|comment_form.input:contentcomment_form.input:_destroy,as::boolean,required:false,label:'Remove'endendf.actionsend但它在输入下添加了“添加新评论”按钮。我怎样才能禁用它,并只为主窗体保留f.ac
我目前正在尝试将ERB布局转换为HAML。这是我不断收到的错误:index.html.haml:18:syntaxerror,unexpected')'));}\n#{_hamlout.format_...这是HAML页面:.row-fluid.span6%h2TodoList.span6%h2{:style=>"text-align:right;"}document.write(today)%hr.divider.row-fluid.span6%h2.small_headNewTask=render:partial=>'layouts/form_errors',:locals=>{:
我使用Ruby编程已经有一段时间了,现在只使用Ruby的标准MRI实现,但我一直对我经常听到的其他实现感到好奇。前几天我在读有关Rubinius的文章,这是一个用Ruby编写的Ruby解释器。我试着在不同的地方查找它,但我很难弄清楚这样的东西到底是如何工作的。我在编译器或语言编写方面从来没有太多经验,但我真的很想弄明白。一门语言究竟如何才能被自己解释?编译中是否有一个我不明白这有意义的基本步骤?有人可以像我是个白痴一样向我解释这个吗(因为无论如何这都不会太离谱) 最佳答案 它比你想象的要简单。Rubinius并非100%用Ruby编
尝试从我的AngularJS端将数据发布到Rails服务器时出现问题。服务器错误:ActionController::RoutingError(Noroutematches[OPTIONS]"/users"):actionpack(4.1.9)lib/action_dispatch/middleware/debug_exceptions.rb:21:in`call'actionpack(4.1.9)lib/action_dispatch/middleware/show_exceptions.rb:30:in`call'railties(4.1.9)lib/rails/rack/logg
为现有模型生成单个文件(_form.html.erb)的命令是什么?在Rails3中工作。谢谢。 最佳答案 这听起来可能很傻,但请听我说完……当我想开始清洁时,我自己也做过几次这样的事情。以下是一个脚本,它将读取您的模式并生成必要的生成命令来重现它:require'rubygems'require'active_support/core_ext'schema=File.read('db/schema.rb')schema.scan(/create_table"(\w+)",.*?\n(.*?)\nend/m).eachdo|name
当音乐碰上区块链技术,会擦出怎样的火花?或许周杰伦已经给了我们答案。8月29日下午,B站独家首发周杰伦限定珍藏Demo独家访谈VCR,周杰伦在VCR里分享了《晴天》《青花瓷》《搁浅》《爱在西元前》四首经典歌曲Demo背后的创作故事,并首次公布18年前未发布的神秘作品《纽约地铁》的Demo。在VCR中,方文山和杰威尔音乐提及到“多亏了区块链技术,现在我们可以将这些Demos,变成独一无二具有收藏价值的艺术品,这些Demos可以在薄盒(国内数藏平台)上听到。”如何将音乐与区块链技术相结合,薄盒方面称:“薄盒作为区块链技术服务方,打破传统对于区块链技术只能作为数字收藏的理解。聚焦于区块链技术赋能,在