Re: Form and radio buttons; can't send them correctly



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.
jstucklex@xxxxxxxxxxxxx
==================
.



Relevant Pages

  • Re: following radio & hidden does not work..... help please.
    ... So you query the database for records and present the concatenated fname and lname for the user to choose from. ... This works the same with a radio button or a select statement. ... This is a HTML or PHP question! ...
    (alt.html)
  • Re: following radio & hidden does not work..... help please.
    ... Using a HTML radio button form as previously stated returns all the data as requested. ... The problem seems to be HOW does one get more than one database variable to be to the PHP action program. ... The objective of the form is to use either a or a radio button form so a user can select a person from the database. ...
    (alt.html)
  • Re: Form and radio buttons; cant send them correctly
    ... Newbie to PHP here, no C or other relevant background, so pretty ...     ... you need some understanding of HTML. ... radio buttons and made an on/off or true/false logic indicator out ...
    (comp.lang.php)
  • Re: CORRECT FILE Re: Form and radio buttons; cant send them correctly
    ... Twayne wrote: ... <html xmlns="http://www.w3.org/1999/xhtml"</a>;> ... <?php // Beats me what's going on! ...
    (comp.lang.php)
  • Re: Sending Information to webpage
    ... -Press Radio Button 1 ... -Press Radion Button 2 ... Its been a while since ive done any html and im not all that familiar with php, or cgiMessage Edited by Ix on 04-19-2006 02:44 PM ...
    (comp.lang.labview)