session value and radio button

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Thad

    #1

    session value and radio button

    On one page I have radio buttons below pictures, here is one picture...

    <img src="images/web-aroundworld458c .jpg" width="100" height="51"
    border="0"
    onclick="this.s rc='./images/web-aroundworld458c .jpg';this.heig ht=102;this.wid th=200"
    ondblclick="thi s.src='./images/web-aroundworld458c .jpg';this.heig ht=51;this.widt h=100"
    alt="" /><br />
    <input type="radio" name="image_cho ice" value="lp15-web-aroundworld458c "
    style="width: 35px;"/>LP-15<br />

    ....then I have a link to a page in which if a radio button is chosen, a
    value will be passed to the new page.

    <?php
    $_SESSION['image_choice']=image_choice;
    ?>

    The theory works but what is passed is the wording "image_choi ce" and not
    what I expected...."lp 15-web-aroundworld458c ".

    If the value of image_choice is "lp15-web-aroundworld458c ", then why would
    it return the literal "image_choi ce"?
    How can I get the value of the button to go to the new page?

    Also, does session_start() ; need to be on each php page when passing the
    values between pages?

    Thanks,
    Thad


  • shimmyshack

    #2
    Re: session value and radio button

    On 31 Mar, 23:36, "Thad" <tsob...@cox.ne twrote:
    On one page I have radio buttons below pictures, here is one picture...
    >
    <img src="images/web-aroundworld458c .jpg" width="100" height="51"
    border="0"
    onclick="this.s rc='./images/web-aroundworld458c .jpg';this.heig ht=102;this.wid th=200"
    ondblclick="thi s.src='./images/web-aroundworld458c .jpg';this.heig ht=51;this.widt h=100"
    alt="" /><br />
    <input type="radio" name="image_cho ice" value="lp15-web-aroundworld458c "
    style="width: 35px;"/>LP-15<br />
    >
    ...then I have a link to a page in which if a radio button is chosen, a
    value will be passed to the new page.
    >
    <?php
    $_SESSION['image_choice']=image_choice;
    ?>
    >
    The theory works but what is passed is the wording "image_choi ce" and not
    what I expected...."lp 15-web-aroundworld458c ".
    >
    If the value of image_choice is "lp15-web-aroundworld458c ", then why would
    it return the literal "image_choi ce"?
    How can I get the value of the button to go to the new page?
    >
    Also, does session_start() ; need to be on each php page when passing the
    values between pages?
    >
    Thanks,
    Thad
    Advice: be clearer about what your code is, don't say "I've got this
    and that code", just show us

    Firstly yes session_start needs to be whereever you wish to use the
    session - see http://uk.php.net/session_start
    and secondly
    what is this expected to do?

    <?php
    $_SESSION['image_choice']=image_choice;
    ?>

    don't you mean
    <?php
    $_SESSION['image_choice']=$image_choice;
    ?>

    where $image_choice is what you sent, either $_GET['image_choice'] or
    $_POST['image_choice']
    but you havent actually given enough code to help us help you.

    Comment

    • Thad

      #3
      Re: session value and radio button

      I will try this worded different...

      HTML page 1: I have two radio buttons...
      <?php session_start() ; ?>
      <input type="radio" name="image_cho ice" value="lp13-web-wild165c"
      style="width: 35px;"/>LP-13<br />
      <input type="radio" name="image_cho ice" value="lp14-web-wild289c"
      style="width: 35px;"/>LP-14<br />

      HTML page 2: Problem...on html page 2, how would I show which button was
      pressed?

      Would it be....
      <?php session_start() ;
      echo $_SESSION['image_choice'];
      ?>

      What I am looking to get as a result is lp13-web-wild165c or
      lp14-web-wild289c to be printed to the screen.


      Comment

      • andy.z@blueyonder.com

        #4
        Re: session value and radio button

        In article <5xCPh.114167$K o5.33194@newsfe 08.phx>, tsobota@cox.net says...
        I will try this worded different...
        >
        HTML page 1: I have two radio buttons...
        <?php session_start() ; ?>
        <input type="radio" name="image_cho ice" value="lp13-web-wild165c"
        style="width: 35px;"/>LP-13<br />
        <input type="radio" name="image_cho ice" value="lp14-web-wild289c"
        style="width: 35px;"/>LP-14<br />
        >
        HTML page 2: Problem...on html page 2, how would I show which button was
        pressed?
        >
        Would it be....
        <?php session_start() ;
        echo $_SESSION['image_choice'];
        ?>
        If your form method is POST
        use
        echo $_POST['image_choice'];
        If your form method is GET
        use
        echo $_GET['image_choice'];
        Sessions aren't really relevant to your problem.

        Andy

        Comment

        Working...