sending via http_post_vars

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sanjay123456
    New Member
    • Sep 2006
    • 125

    sending via http_post_vars

    Hello friend ,

    In the following code when user click submit i want to to radio buttton option means
    user click 1 ,2 ,3 or 4
    means its print tha option

    but it snot print

    can any body help me ?

    [PHP]
    <html>
    <BODY>
    <table border='0'><tr> <td valign='top'><i nput

    type='radio' name='quiz' value='1' />a</td><td>
    <br></td></tr><tr><td valign='top'><i nput

    type='radio' name='quiz' value='2' />b</td><td>
    <br></td></tr><tr><td valign='top'><i nput

    type='radio' name='quiz' value='3' />c</td><td>
    <br></td></tr><tr><td valign='top'><i nput

    type='radio' name='quiz' value='4' />d</td><td>
    <br></td></tr></table><br></p></form>

    </BODY></html>

    <?php

    echo $HTTP_POST_VARS['quiz'];

    ?>

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

    <html><head><ti tle>Questionnai re</title></head>

    <body>

    <form name="myform" action="http://localhost//my1.php" method="post">

    <input type="submit" name="submitted " value="submit" />

    <input type="hidden" name="que" value="<?=$HTTP _POST_VARS['quiz']?>">

    </form></body></html>
    [/PHP]


    sanjay
  • ronverdonk
    Recognized Expert Specialist
    • Jul 2006
    • 4259

    #2
    You must include the input field radio buttons witihin your FORM, Then, after submission, the clicked items will be passed via the $_POST variable.

    (Do not use the HTTP_* vars, because they are deprecated and will no longer be available in PHP 6, use $_POST instead).

    Ronald :cool:

    Comment

    • sanjay123456
      New Member
      • Sep 2006
      • 125

      #3
      Sir

      i replace $HTTP_POST_VARS by
      $_POST but its not print option just like 1 ,2 and 3
      i am using php 5


      sanjay

      Comment

      • Atli
        Recognized Expert Expert
        • Nov 2006
        • 5062

        #4
        Hi. I'm sorry but I didn't understand what your trying to do.

        A couple of things I noticed tho..
        Were there more than one file posted there? Cuz if this was all one file id try not to open and close <html> tags all over the place.. and I wouldnt echo things after I close a html tag.

        A form tag must be posted using a submit button (or scripts) before teh php can take it as $_Post data

        This is a simple way to do what I think your trying to do...

        [PHP]if(isset($_POST['Posted']))
        {
        echo "Option selected : ". $_POST['opt'] ."<br>";
        }

        ?>
        <form action="?" method="post">
        <input type="radio" name="opt" value="1" /> 1<br>
        <input type="radio" name="opt" value="2" /> 2<br>
        <input type="radio" name="opt" value="3" /> 3<br>
        <input type="radio" name="opt" value="4" /> 4<br><br>
        <input type="submit" name="Posted" value="Select" />
        </form>
        <?[/PHP]

        Comment

        • ronverdonk
          Recognized Expert Specialist
          • Jul 2006
          • 4259

          #5
          Originally posted by ronverdonk
          You must include the input field radio buttons witihin your FORM, Then, after submission, the clicked items will be passed via the $_POST variable.

          (Do not use the HTTP_* vars, because they are deprecated and will no longer be available in PHP 6, use $_POST instead).

          Ronald :cool:
          Don't do just part 2 of my reply. Take note of part 1, which says that you can must include your buttons within the form, then submit it, and only after submission you can retrieve the values via $_POST!

          Ronald :cool

          Comment

          • theRamones
            New Member
            • Nov 2006
            • 13

            #6
            [html]
            <html><head><ti tle>Questionnai re</title></head>

            <body>

            <form name="myform" action="http://localhost//my1.php" method="post">

            <table border='0'><tr> <td valign='top'><i nput

            type='radio' name='quiz' value='1' />a</td><td>
            <br></td></tr><tr><td valign='top'><i nput

            type='radio' name='quiz' value='2' />b</td><td>
            <br></td></tr><tr><td valign='top'><i nput

            type='radio' name='quiz' value='3' />c</td><td>
            <br></td></tr><tr><td valign='top'><i nput

            type='radio' name='quiz' value='4' />d</td><td>
            <br></td></tr></table><br></p>

            <input type="submit" name="submitted " value="submit" />

            <input type="hidden" name="que" value="<?=$HTTP _POST_VARS['quiz']?>">

            </form>

            </BODY></html>

            <?php
            // this line will print nothing
            echo $HTTP_POST_VARS['quiz'];

            ?>
            [/html]

            Comment

            Working...