advice on if statements

Discussion in 'PHP' started by greenstar91, May 18, 2008.

  1. #1
    http://greenstar91.007sites.com/index.txt

    This is my code

    As you can see there is a check box in my form which is not being used yet. When the user checks the box and the submit button is pressed i want code to be executed much like the echo statements when it is not checked currently. can anyone suggest how i would go about this?

    Thanks
     
    greenstar91, May 18, 2008 IP
  2. sebkohl

    sebkohl Peon

    Messages:
    12
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    if (isset($_POST["repeat"]) and $_POST["repeat"] == "on") {

    echo "checkbox is checked";

    }
     
    sebkohl, May 18, 2008 IP
  3. zerxer

    zerxer Peon

    Messages:
    368
    Likes Received:
    18
    Best Answers:
    0
    Trophy Points:
    0
    #3
    The value of 'repeat' is 'check' again not 'on'
     
    zerxer, May 18, 2008 IP
  4. samyak

    samyak Active Member

    Messages:
    280
    Likes Received:
    7
    Best Answers:
    4
    Trophy Points:
    90
    #4
    All you have to do is check is post variable "repeat" is set. i.e.

    if (isset($_POST["repeat"]))

    No need to check its values. The chek boxes are posted only if it is checked so the simple test suffices.
     
    samyak, May 19, 2008 IP
  5. ksamir2004

    ksamir2004 Peon

    Messages:
    70
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Hi ,

    if u will take my suggestion then i can say use java script for this.

    http://www.dynamicdrive.com/dynamicindex16/acceptterm.htm

    hope you will understand every thing.


     
    ksamir2004, May 19, 2008 IP
  6. greenstar91

    greenstar91 Guest

    Messages:
    221
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #6
    thanks to those who have posted i will trying the suggestion out later today
     
    greenstar91, May 19, 2008 IP