By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,481 Members | 3,170 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,481 IT Pros & Developers. It's quick & easy.

Form and radio buttons; can't send them correctly

P: n/a
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


Jun 27 '08 #1
Share this Question
Share on Google+
11 Replies


P: n/a
On Mon, 02 Jun 2008 20:06:35 +0200, Twayne <no****@devnull.spamcop.net
wrote:
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.
Below are all EXACT pastes, not hand typed & not touched otherwise:
<input type="radio" name="item" <value = "0">0
You HTML is broken, always validate you pages (http://validator.w3.org),
it would have told you almost instantly you inputs were malformed (which
saves you a lot of time).

In case you don't notice: lose the extra < before value:
<input type="radio" name="item" value="0">
--
Rik Wasmus
....spamrun finished
Jun 27 '08 #2

P: n/a
Twayne wrote:
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

In addition to what Rik said - it is $_POST['item'], not $post['item'].

And before you learn PHP, you need some understanding of HTML. If you
don't have correct HTML, there is nothing you can do in PHP to make
things work.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Jun 27 '08 #3

P: n/a
On Mon, 02 Jun 2008 20:06:35 +0200, Twayne
<no****@devnull.spamcop.netwrote:
>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.
>Below are all EXACT pastes, not hand typed & not touched otherwise:
><input type="radio" name="item" <value = "0">0

You HTML is broken, always validate you pages
(http://validator.w3.org), it would have told you almost instantly
you inputs were malformed (which saves you a lot of time).

In case you don't notice: lose the extra < before value:
<input type="radio" name="item" value="0">
GAK! Thanks, Ric! Looks like I bungled a Search & Destroy somewhere
along the line. I did do a few "desparate" moves out of frustration;
thought I'd fixed it all after a coffee-break.

Thanks!
Jun 27 '08 #4

P: n/a
WARNING: A very thick-skulled, occasionally myopic OP bottom posted a
response to Jerry:
Twayne wrote:
>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.
....
>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>
...
============
....
>>

In addition to what Rik said - it is $_POST['item'], not
$post['item'].
And before you learn PHP, you need some understanding of HTML. If you
don't have correct HTML, there is nothing you can do in PHP to make
things work.

Thanks, Jerry. The "<value" was an aberration of frustration, I think;
no other reason for it to be there. I'm no guru at HTML but I do know
better. I broke the lines up that way to keep them all onscreen without
having to scroll horizontally. It's gone and a new ZIP made<g>. Poor
houskeeping, I know.

I assume the '$post' you're talking about is here:
if(isset($post['item'])){$_item = $post['item'];}else{$_item = '';} ?

Making the '$post' to $_POST change was no help, BUT ... I think I have
to back up and get another head-around on this. I thought I'd figured
out what the syntax of all the line parts meant, but apparently I'm
still not getting it straight.

I'll let you know either way whether I get it working or have another
question.

Thanks much,

Twayne

Jun 27 '08 #5

P: n/a
Twayne wrote:
WARNING: A very thick-skulled, occasionally myopic OP bottom posted a
response to Jerry:
>Twayne wrote:
>>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.
...
>>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>
...
============
...
>In addition to what Rik said - it is $_POST['item'], not
$post['item'].
And before you learn PHP, you need some understanding of HTML. If you
don't have correct HTML, there is nothing you can do in PHP to make
things work.


Thanks, Jerry. The "<value" was an aberration of frustration, I think;
no other reason for it to be there. I'm no guru at HTML but I do know
better. I broke the lines up that way to keep them all onscreen without
having to scroll horizontally. It's gone and a new ZIP made<g>. Poor
houskeeping, I know.

I assume the '$post' you're talking about is here:
if(isset($post['item'])){$_item = $post['item'];}else{$_item = '';} ?

Making the '$post' to $_POST change was no help, BUT ... I think I have
to back up and get another head-around on this. I thought I'd figured
out what the syntax of all the line parts meant, but apparently I'm
still not getting it straight.

I'll let you know either way whether I get it working or have another
question.

Thanks much,

Twayne
Sorry, from your post it looked like you weren't familiar with HTML. We
sometimes get people here who don't understand HTML much (if at all),
and they complain because their PHP isn't working. When in reality the
problem is back in the HTML. And your error is very typical of the type
of error those people make.

If you are familiar with HTML, then my apologies.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Jun 27 '08 #6

P: n/a
Twayne wrote:
>WARNING: A very thick-skulled, occasionally myopic OP bottom posted a
response to Jerry:
>>Twayne wrote:
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.
...
>>>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>
...
============
...
>>In addition to what Rik said - it is $_POST['item'], not
$post['item'].
And before you learn PHP, you need some understanding of HTML. If
you don't have correct HTML, there is nothing you can do in PHP to
make things work.


Thanks, Jerry. The "<value" was an aberration of frustration, I
think; no other reason for it to be there. I'm no guru at HTML but
I do know better. I broke the lines up that way to keep them all
onscreen without having to scroll horizontally. It's gone and a new
ZIP made<g>. Poor houskeeping, I know.

I assume the '$post' you're talking about is here:
if(isset($post['item'])){$_item = $post['item'];}else{$_item = '';}
?

Making the '$post' to $_POST change was no help, BUT ... I think I
have to back up and get another head-around on this. I thought I'd
figured out what the syntax of all the line parts meant, but
apparently I'm still not getting it straight.

I'll let you know either way whether I get it working or have another
question.

Thanks much,

Twayne

Sorry, from your post it looked like you weren't familiar with HTML.
We sometimes get people here who don't understand HTML much (if at
all), and they complain because their PHP isn't working. When in
reality the problem is back in the HTML. And your error is very
typical of the type of error those people make.

If you are familiar with HTML, then my apologies.


Hi,

AB-SO-LUTELY no need to apologize; I understand completely! Plus, you
don't know me from Adam since I've not posted to the PHP groups before.

Unfortunately though, I'm still stuck. But the good news is, I don't
think the "problem" is in any of the code I posted: The bad news is, I
don't think the "problem" is in any of the code I posted.
Somehow, in some way, I've apparently created booleans for the radio
buttons and made an on/off or true/false logic indicator out of a set
of radio buttons! HOW that happens is complete news to me! But I quit
for the day; tomorrow it'll look fresher to me.
Jeez, I hope it's not an HTML screwup<G>! I can tell I'll never hear
the end of it if it is!

I rewrote the code and created a stub that is identical to the
non-working code, except it ONLY has the one radion button category for
the form; nothing else is on/in the form visually or codewise but the
one catefory of radio buttons. It works perfectly.
So, I made a 2-column chart in OOo and placed the relevant code from
one in one column, and the other program's code in the second column.
They are exactly the same codewise! Unless I screwed up the macro I
wrote, they are character for character identical except at the
beginning and very end. And, without the "<value..." et al <g>.

I'll start in fresh on it tomorrow.

It's a lost cause and unless you have a constant-width font, this will
be a mess, but here's the comparison columns:
I figured it can't hurt to try for those who are curious.
TEST STUB, working
REAL CODE, not working

<Div class = "radio">

Would you like a resonse? &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>

<br><br>
<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>

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

echo "Item? <br\"" . $_item . "\" <br><br>";
echo "Item Rating: <br\"" . $_item . "\" <br><br>";

Item: '. $_item . '<br>
item: '. $_item .' <br>

Regards,

Twayne

Jun 27 '08 #7

P: n/a
Twayne wrote:
> Twayne wrote:
WARNING: A very thick-skulled, occasionally myopic OP bottom posted a
response to Jerry:

Twayne wrote:
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.
...
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>
...
============
...
In addition to what Rik said - it is $_POST['item'], not
$post['item'].
And before you learn PHP, you need some understanding of HTML. If
you don't have correct HTML, there is nothing you can do in PHP to
make things work.


Thanks, Jerry. The "<value" was an aberration of frustration, I
think; no other reason for it to be there. I'm no guru at HTML but
I do know better. I broke the lines up that way to keep them all
onscreen without having to scroll horizontally. It's gone and a new
ZIP made<g>. Poor houskeeping, I know.

I assume the '$post' you're talking about is here:
if(isset($post['item'])){$_item = $post['item'];}else{$_item = '';}
?

Making the '$post' to $_POST change was no help, BUT ... I think I
have to back up and get another head-around on this. I thought I'd
figured out what the syntax of all the line parts meant, but
apparently I'm still not getting it straight.

I'll let you know either way whether I get it working or have another
question.

Thanks much,

Twayne

Sorry, from your post it looked like you weren't familiar with HTML.
We sometimes get people here who don't understand HTML much (if at
all), and they complain because their PHP isn't working. When in
reality the problem is back in the HTML. And your error is very
typical of the type of error those people make.

If you are familiar with HTML, then my apologies.

Hi,

AB-SO-LUTELY no need to apologize; I understand completely! Plus, you
don't know me from Adam since I've not posted to the PHP groups before.

Unfortunately though, I'm still stuck. But the good news is, I don't
think the "problem" is in any of the code I posted: The bad news is, I
don't think the "problem" is in any of the code I posted.
Somehow, in some way, I've apparently created booleans for the radio
buttons and made an on/off or true/false logic indicator out of a set
of radio buttons! HOW that happens is complete news to me! But I quit
for the day; tomorrow it'll look fresher to me.
Jeez, I hope it's not an HTML screwup<G>! I can tell I'll never hear
the end of it if it is!

I rewrote the code and created a stub that is identical to the
non-working code, except it ONLY has the one radion button category for
the form; nothing else is on/in the form visually or codewise but the
one catefory of radio buttons. It works perfectly.
So, I made a 2-column chart in OOo and placed the relevant code from
one in one column, and the other program's code in the second column.
They are exactly the same codewise! Unless I screwed up the macro I
wrote, they are character for character identical except at the
beginning and very end. And, without the "<value..." et al <g>.

I'll start in fresh on it tomorrow.

It's a lost cause and unless you have a constant-width font, this will
be a mess, but here's the comparison columns:
I figured it can't hurt to try for those who are curious.


TEST STUB, working

REAL CODE, not working

<Div class = "radio">

Would you like a resonse? &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>

<br><br>

<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>

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

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

echo "Item? <br\"" . $_item . "\" <br><br>";

echo "Item Rating: <br\"" . $_item . "\" <br><br>";

Item: '. $_item . '<br>

item: '. $_item .' <br>
Regards,

Twayne
OK, if you're expecting the be able to get the value of the radio button
in the same page that you wrote the radio button, it won't work (unless
the page is resubmitted). i.e.

<div>
<input type="radio" name="item" <value = "0">0
<input type="radio" name="item" <value = "1">1
value = "<?php if(isset($_POST['item'])){echo $_POST['item'];} ?>" </div>

$_POST['item'] will never be set unless your form submits the request
back to the same page. This is because PHP is server side - and all PHP
is executed before the page is ever sent to the browser. I don't know
if you're doing this or not - you didn't give all of the code. But the
code you show won't work. Other than that, I don't see any obvious
problems.

Also, in your php.ini file, enable all errors and display them:

error_reporting=E_ALL
display_errors = on

You should always have this set in a development system (but never in a
production system). They might help show something I'm not seeing.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Jun 27 '08 #8

P: n/a
Twayne wrote:
>> Twayne wrote:
WARNING: A very thick-skulled, occasionally myopic OP bottom
posted a response to Jerry:

Twayne wrote:
>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.
...
>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>
>...
>============
...
In addition to what Rik said - it is $_POST['item'], not
$post['item'].
And before you learn PHP, you need some understanding of HTML. If
you don't have correct HTML, there is nothing you can do in PHP to
make things work.


Thanks, Jerry. The "<value" was an aberration of frustration, I
think; no other reason for it to be there. I'm no guru at HTML but
I do know better. I broke the lines up that way to keep them all
onscreen without having to scroll horizontally. It's gone and a
new ZIP made<g>. Poor houskeeping, I know.

I assume the '$post' you're talking about is here:
if(isset($post['item'])){$_item = $post['item'];}else{$_item =
'';} ?

Making the '$post' to $_POST change was no help, BUT ... I think I
have to back up and get another head-around on this. I thought I'd
figured out what the syntax of all the line parts meant, but
apparently I'm still not getting it straight.

I'll let you know either way whether I get it working or have
another question.

Thanks much,

Twayne


Sorry, from your post it looked like you weren't familiar with
HTML. We sometimes get people here who don't understand HTML much
(if at all), and they complain because their PHP isn't working.
When in reality the problem is back in the HTML. And your error
is very typical of the type of error those people make.

If you are familiar with HTML, then my apologies.

Hi,

AB-SO-LUTELY no need to apologize; I understand completely! Plus,
you don't know me from Adam since I've not posted to the PHP groups
before. Unfortunately though, I'm still stuck. But the good news is,
I don't
think the "problem" is in any of the code I posted: The bad news
is, I don't think the "problem" is in any of the code I posted.
Somehow, in some way, I've apparently created booleans for the
radio buttons and made an on/off or true/false logic indicator out
of a set of radio buttons! HOW that happens is complete news to me!
But I quit for the day; tomorrow it'll look fresher to me.
Jeez, I hope it's not an HTML screwup<G>! I can tell I'll never
hear the end of it if it is!

I rewrote the code and created a stub that is identical to the
non-working code, except it ONLY has the one radion button category
for the form; nothing else is on/in the form visually or codewise
but the one catefory of radio buttons. It works perfectly.
So, I made a 2-column chart in OOo and placed the relevant code
from one in one column, and the other program's code in the second
column. They are exactly the same codewise! Unless I screwed up the
macro I wrote, they are character for character identical except at
the beginning and very end. And, without the "<value..." et al <g>.

I'll start in fresh on it tomorrow.

It's a lost cause and unless you have a constant-width font, this
will be a mess, but here's the comparison columns:
I figured it can't hurt to try for those who are curious.


TEST STUB, working

REAL CODE, not working

<Div class = "radio">

Would you like a resonse? &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>

<br><br>

<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'];} ?>"
</divif(isset($post['item'])){$_item = $post['item'];}else{$_item =
'';}

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

echo "Item? <br\"" . $_item . "\" <br><br>";

echo "Item Rating: <br\"" . $_item . "\" <br><br>";

Item: '. $_item . '<br>

item: '. $_item .' <br>
Regards,

Twayne

OK, if you're expecting the be able to get the value of the radio
button in the same page that you wrote the radio button, it won't
work (unless the page is resubmitted). i.e.

<div>
<input type="radio" name="item" <value = "0">0
<input type="radio" name="item" <value = "1">1
value = "<?php if(isset($_POST['item'])){echo $_POST['item'];} ?>"
</div>
$_POST['item'] will never be set unless your form submits the request
back to the same page. This is because PHP is server side - and all
PHP is executed before the page is ever sent to the browser. I don't
know if you're doing this or not - you didn't give all of the code.
But the code you show won't work. Other than that, I don't see any
obvious problems.
Oh; sorry, yes, I probably should have included that; assumed it would
be assumed. Sorry.
Rest assured, the code is indeed working, just as I described.
>
Also, in your php.ini file, enable all errors and display them:

error_reporting=E_ALL
display_errors = on
That sounds like good advice; will do. Thanks!
>
You should always have this set in a development system (but never in
a production system). They might help show something I'm not seeing.
Looking at it again today afresh, I think my attack to the problem was
wrong yesterday. Instead of building a stub I should have started
ripping apart the orginal problem code and eliminating things until it's
simple enough to see better and analyze. THAT is what I should have
presented here.

I'll be back; not sure when I can get back to it but should be able to
give it an hour or so today.

Regards & thanks,

Twayne
Jun 27 '08 #9

P: n/a
SCRATCH THAT POST! COPIED WRONG FILE!! GOTTA GO - WILL BE BACK LATER
TODAY/TOMORROW. APOLOGIES!
Jun 27 '08 #10

P: n/a
rf
"Twayne" <no****@devnull.spamcop.netwrote in news:MuC1k.5624$Ev.3259
@trndny09:
>><input type="radio" name="item" <value =1>
<input type="radio" name="item" <value = '2'>2
<input type="radio" name="item" <value = '3'>3
>Looks like the problem is the input statements. I would expect them to
look like this:

<input type="radio" name="item" value='1'>Option 1
<input type="radio" name="item" value='2'>Option 2
<input type="radio" name="item" value='3'>Option 3

Note the value attribute SHOULD NOT be <value.

Fix that first and then tell us what happens.
[ Horribly shamed, Twayne despondently wrote:

Oh ... my ... goodness ... I just knew it'd be something silly/stupid
like that! Story of my life!
You would not believe how many times I went through that stupid code
looking to be sure all tags etc. were in pairs!
If you had shown your HTML to the validator over at
http://validator.w3.org/
you would have immediately known what the problem was. The validator is
much better than you or I at spotting syntax errors.

--
Richard
Killing all google groups posts
The Usenet Improvement Project: http://improve-usenet.org
Jun 27 '08 #11

P: n/a
"Twayne" <no****@devnull.spamcop.netwrote in news:MuC1k.5624$Ev.3259
@trndny09:
....
>
If you had shown your HTML to the validator over at
http://validator.w3.org/
you would have immediately known what the problem was. The validator
is much better than you or I at spotting syntax errors.

Actually, it didn't immediately point out what the problem was, and I
didn't expect it to, because the "problem" code was too hard to see in
amongst the suggestive code. By suggestive code I mean non-recommended,
ok here but not there, etc. etc.. The power of the validator is to the
latest syntax, which is great and a good achievement, but it takes time
to wheedle it down to expose a specific reason for a problem time I
didn't have.

It's a long story why I was in such a rush and didn't turn to the
validators sooner (besides not thinking of them at first<g>). The
validators are great but they aren't always the fastest way to get
something working in a specific set of browsers while at the same time
discovering PHP has a lot steeper learning curve than I expected, so PHP
was getting my main attention spans.
FWIW, I passed the original, complete code thru the validator this am
and am having pretty good luck with the cleanups.

Just wanted to let folks know the validator advice didn't fall on "deaf"
ears; blind eyes, whatever.

Regards,

Twayne
Jun 27 '08 #12

This discussion thread is closed

Replies have been disabled for this discussion.