php checkbox form validation

Discussion in 'Software' started by izzysanime, Apr 4, 2007.

  1. izzysanime

    izzysanime Private E-2

    Here is my issue, No matter what I select, yes or no, it always displays the same response. In this case it alwayhs displays the error.

    I have also used a checkbox and that does not work. I see that is what is used for the checkbox on this forum, can someone send me that code or something?

    any ideas

    if($t27=="1"){
    echo "<script language=Javascript>alert('Thank You for Agreeing to Terms & Conditions');</script>";
    // ... checkbox1 has been checked, form processing code here
    } else {
    echo "<script language=Javascript>alert('Error! You must agree to the terms and conditions!');history.back(-1);</script>"; // ... checkbox1 has NOT been checked, form processing code here
    }

    This is the html part of the form

    <select name="t27" id="t27">
    <option value="1">Yes</option>
    <option value="0" selected="selected">No</option>
    </select>

    Thanks
    Josh
     
  2. noahawk

    noahawk Corporal

    Are registered globals turned on? If they are, then it should be passing the value, otherwise, you may need to use $_POST['t27'], $_GET['t27'], or $_SERVER['t27'].

    I can't remember if
    doesn't need the selected=" " part. It may just need selected there. And if you are using radio buttons, it should just be "checked" without quotes.
     
  3. izzysanime

    izzysanime Private E-2

    ok, $_POST['tsomenumber'] for others where being used. This was not originally my script, I tried adding that $_POST['t27'] before, but for some reason is was still being though of as not filled. If I required it, the error message would also pop up saying that all the required forms where filed.

    Thanks
    Josh
     
  4. izzysanime

    izzysanime Private E-2

    hmm, odd, but it works now. - thats exactly what i did before, well, I did not give the checbox a value=1 before, maybe thats it. hmm, thanks for your help.

    Thanks
    Josh
     
  5. noahawk

    noahawk Corporal

    You're welcome. Come back for more answers if you have any more questions
     

MajorGeeks.Com Menu

Downloads All In One Tweaks \ Android \ Anti-Malware \ Anti-Virus \ Appearance \ Backup \ Browsers \ CD\DVD\Blu-Ray \ Covert Ops \ Drive Utilities \ Drivers \ Graphics \ Internet Tools \ Multimedia \ Networking \ Office Tools \ PC Games \ System Tools \ Mac/Apple/Ipad Downloads

Other News: Top Downloads \ News (Tech) \ Off Base (Other Websites News) \ Way Off Base (Offbeat Stories and Pics)

Social: Facebook \ YouTube \ Twitter \ Tumblr \ Pintrest \ RSS Feeds