save value in different variable
Results 1 to 5 of 5

Thread: save value in different variable

  1. #1
    Junior Member
    Join Date
    Apr 2012
    Posts
    21

    Post save value in different variable

    in action.html file
    My HTML Form has Radio Buttons.
    when I submit the form.
    I get the values in action.php file.
    I want to save the value in variable.
    so that , If i submit the Form again.
    it should be save its value in another variable.
    If there are 3 radio buttons then I should get three variables having values of these radio buttons.
    How can I get . please guide me. thanks.

  2. #2
    Settled 4 red convertible dalecosp's Avatar
    Join Date
    Jul 2002
    Location
    Accelerating Windows at 9.81 m/s....
    Posts
    7,716
    If you want values to remain, consider using PHP sessions.

    HTH,
    /!!\ mysql_ is deprecated --- don't use it! Tell your hosting company you will switch if they don't upgrade! /!!!\ ereg() is deprecated --- don't use it!

    dalecosp "God doesn't play dice." --- Einstein "Perl is hardly a paragon of beautiful syntax." --- Weedpacket

    Getting Help at All --- Collected Solutions to Common Problems --- Debugging 101 --- Unanswered Posts --- OMBE: Office Machines, Business Equipment

  3. #3
    Un Re Member cretaceous's Avatar
    Join Date
    Sep 2004
    Location
    London UK
    Posts
    940
    echo the posted value back into the same checkbox (assuming all script is on one page)
    PHP Code:
    echo "<input type='checkbox' name='foo' value='1'";
    if (
    $_POST['foo']==1) echo "checked='checked'"
    echo 
    ">"

  4. #4
    Junior Member
    Join Date
    Apr 2012
    Posts
    21

    Post

    echo "<input type='checkbox' name='foo' value='1'";
    if ($_POST['foo']==1) echo "checked='checked'";
    echo ">";

    Dear, u mean,




    <input type='radio' name='foo' value='1'";
    <input type='radio' name='foo' value='2'";
    <input type='radio' name='foo' value='3'";
    if ($_POST['foo']==1)
    $vone=1 ;
    esle if ($_POST['foo']==2)
    $vtwo=2;
    else($_POST['foo']==3)
    $vthree=3;

  5. #5
    Un Re Member cretaceous's Avatar
    Join Date
    Sep 2004
    Location
    London UK
    Posts
    940
    no - not like that - you are mixing the input elements with php code
    (sorry - I misread it as checkboxes, you asked for radio buttons)

    the radio buttons must each be closed with '>'

    just do this at start of your script:
    if ($_POST['foo']==1)
    $vone=1 ;
    else if ($_POST['foo']==2)
    $vtwo=2;
    else($_POST['foo']==3)
    $vthree=3;

    and when a value matches in the three radio button inputs echo "checked='checked'";

    (but you should be able to do it without the additional variables)

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •