表格和单选按钮;无法正确发送它们 [英] Form and radio buttons; can't send them correctly

查看:36
本文介绍了表格和单选按钮;无法正确发送它们的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




这里有新手到PHP,没有C或其他相关背景,所以非常niave

w / r对细微差别等等我想这是非常基本的。


XP专业版,SP2 +,PHP 4.4.7,XAMPP本地Apache服务器6.我认为

并作为服务运行,使用NoteTab Pro作为IDE(效果很好)。如果

你需要更多,请问。


在一个功能形式:

我有一个3个选项的单选按钮,是的,不,不在乎。它有效。

罚款。


在*问题*表单中我有一个单选按钮类别有11个选项:

来自0到10.


如果单击* no *按钮,我会得到预期的&;回应

提交。看起来很好。


但如果点击(勾选)11个按钮中的任何*,我只能获得*

" on" *而不是我期望的数字。我不知道on

来自何处,也不知道为什么一种形式有效,一种形式无效;它们和

尽可能相同,并且没有任何数量的小提琴似乎会改变回应开启。而不是x而不是x。我期待的价值。它是

但是如果检查了任何内容,它会给出消息on,但上面提到的

工作表格不会这样做。


我可以发布更多或完整的代码,如果你问,但我不认为你想要通过这一切来挖掘b
。以下是我认为

代码的相关部分。我愿意接受所有的建议,包括提供更多代码,如果

它会帮助任何事情。我有一个网站,我可以把它下载。

这些都没有上传到真实网站,但是......我是

运行完全相同的本地Apache& PHP就像在网站上一样。我还没有切换到PHP 5。

以下是所有精确的贴纸,而不是手工打印的贴纸。否则没有触及:


来自工作表:

主要部分:

--------- ---

< Div class =" radio">

您想要一个共鸣吗? & nbsp& nbsp

< input type =" radio"命名= QUOT;响应" value ="是">是 -

< input type =" radio"命名= QUOT;响应" value =" No"> No -

< input type =" radio"命名= QUOT;响应"值=不在乎它没有

问题< br>< br>

value ="<?php if(isset( $ _POST [''回复''])){echo $ _POST [''回复''];}?>"

/>< / div>

[注意我不知道/>是什么是或是但它没有b $ b似乎关心它是否存在!它来自

一些代码,我沿着这条线刮下了某些东西]


---------------

和result.php;

....

if(isset($ post [''response''])){$ _回复= $ post [''response''];} else {$ _ response

='''';}

....

....

echo"回复? < br\"" 。 $ _respond。 " \" < br>< br>" ;;

....

$ mail_body =''

..

回复:''。 $ _respond。 ''< br>

....


正如我所说,一切正常。

=== ====================

在问题表格中(差异名称):

主要部分:

-------------------

< Div class =" radio">

购买的商品:& nbsp& nbsp

< input type =" radio"命名= QUOT;项目" < value =" 0"> 0

< input type =" radio"命名= QUOT;项目" < value =" 1"> 1

< input type =" radio"命名= QUOT;项目" < value =" 2" 2

< input type =" radio"命名= QUOT;项目" < value =" 3" 3

< input type =" radio"命名= QUOT;项目" < value =" 4" 4

< input type =" radio"命名= QUOT;项目" < value =" 5" 5

< input type =" radio"命名= QUOT;项目" < value =" 6" 6

< input type =" radio"命名= QUOT;项目" < value =" 7" 7

< input type =" radio"命名= QUOT;项目" < value =" 8" 8

< input type =" radio"命名= QUOT;项目" < value =" 9" 9

< input type =" radio"命名= QUOT;项目" < value =" 10" 10

< value ="<?php if(isset($ _ POST [''item''])){echo $ _POST [''item ''];}?>"

< / div>

------------------


结果.php:

....

if(isset($ post [''item''] )){$ _ item = $ post [''item''];} else {$ _ item ='''';}

....

echo" ;项目评级:< br\"" 。 $ _item。 " \" < br>< br>" ;;

....

$ mail_body =''

..

项目:''。 $ _item。''< br>

....

============


正如我所说,勾选其中任何一项都会让我开启。当值

回显到屏幕而不是预期的数字字符时。

单选按钮在表单上正常运行;只有一次可以检查,

等..


任何提示/协助/建议非常感谢,


TIA,


Twayne

解决方案

_POST [''回复''])){echo


_POST [''response''];}?>"

/>< / div>

[注意我不知道/>是什么是或是但它没有b $ b似乎关心它是否存在!它来自

一些代码,我沿着这条线刮下了某些东西]


---------------

和result.php;

....

if(isset(


post [' '响应''])){

Hi,

Newbie to PHP here, no C or other relevant background, so pretty niave
w/r to the nuances etc. but I think this is pretty basic.

XP Pro, SP2+, PHP 4.4.7, XAMPP Local Apache Server 6.something I think
and running as a service, Using NoteTab Pro as an IDE (works well). If
you need more, just ask.

In one functioning form:
I have a radio button with 3 choices, Yes, No, Don''t Care. It works
fine.

In the *problem* form I have a radio button category with 11 choices:
Ratings from 0 to 10.

If *no* button is clicked, I get the expected "" echoed on
Submitting. Seems fine.

But if *any* of the 11 buttons are clicked (ticked), I only get *
"on" * instead of the digits I expect. I have NO idea where the "on"
comes from, nor why one form works and one doesn''t; they are as
reasonably identical as possible and no amount of fiddling will seem to
change echoing the "on" instead of the "x" value I expect. It''s as
though if anything is checked, it gives the message "on", but the
working form mentioned above does not do that.

I can post more, or full code, if you ask, but I don''t think you want to
dig thru all that. Here are what I think are the relevant parts of the
code. I''m open to any all all advice, including providing more code if
it''ll help anything. I do have a web site I can put it on for download.
None of this has been uploaded to a real site yet, but ... I''m
running the exact same local Apache & PHP as is on the web site. I have
not switched to PHP 5 yet.
Below are all EXACT pastes, not hand typed & not touched otherwise:

From the Working Form:
In Main part:
------------
<Div class = "radio">
Would you like a resonse? &nbsp &nbsp
<input type="radio" name="respond" value="Yes">Yes -
<input type="radio" name="respond" value="No">No -
<input type="radio" name="respond" value="Don''t Care"It does not
matter <br><br>
value="<?php if(isset($_POST[''respond''])){echo $_POST[''respond''];} ?>"
/></div>
[ NOTE I have no idea what the "/>" is or does but it doesn''t
seem to care whether it''s there or not! It came from
some code I scraped somwhere along the line ]

---------------
and in the result.php;
....
if(isset($post[''respond''])){$_respond = $post[''respond''];}else{$_respond
= '''';}
....
....
echo "Respond? <br\"" . $_respond . "\" <br><br>";
....
$mail_body = ''
..
Respond: ''. $_respond . ''<br>
....

As I said, that all works fine.
=======================
In the PROBLEM form (diff var name):
In Main Part:
-------------------
<Div class = "radio">
Item/s purchased: &nbsp &nbsp
<input type="radio" name="item" <value = "0">0
<input type="radio" name="item" <value = "1">1
<input type="radio" name="item" <value = "2"2
<input type="radio" name="item" <value = "3"3
<input type="radio" name="item" <value = "4"4
<input type="radio" name="item" <value = "5"5
<input type="radio" name="item" <value = "6"6
<input type="radio" name="item" <value = "7"7
<input type="radio" name="item" <value = "8"8
<input type="radio" name="item" <value = "9"9
<input type="radio" name="item" <value = "10"10
<value = "<?php if(isset($_POST[''item''])){echo $_POST[''item''];} ?>"
</div>
------------------

And the result.php:
....
if(isset($post[''item''])){$_item = $post[''item''];}else{$_item = '''';}
....
echo "Item Rating: <br\"" . $_item . "\" <br><br>";
....
$mail_body = ''
..
item: ''. $_item .'' <br>
....
============

As I said, ticking any one of those items gives me "on" when the value
is echoed to the screen instead of the expected digit character. The
radio buttons function correctly on the form; only once can be checked,
etc..

Any hints/assistance/advice very much appreciated,

TIA,

Twayne


解决方案

_POST[''respond''])){echo


_POST[''respond''];} ?>"
/></div>
[ NOTE I have no idea what the "/>" is or does but it doesn''t
seem to care whether it''s there or not! It came from
some code I scraped somwhere along the line ]

---------------
and in the result.php;
....
if(isset(


post[''respond''])){


这篇关于表格和单选按钮;无法正确发送它们的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆