Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4025530
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T10:51:29+00:00 2026-05-20T10:51:29+00:00

I have this code to check that my ToS checkbox is checked: if (!isset($_POST[‘tosagree’]))

  • 0

I have this code to check that my ToS checkbox is checked:

if (!isset($_POST['tosagree'])) {//if the user did not agree to ToS
    $errors[] = '<span>Please agree to the Terms of Service.<span>';
}

For some reason it is allowing me to register even with that code there. The weird thing is that if any other field is not field and that field is not checked it will print the error, but if that is the only problem it allows the user to register.

Update: seems like its a problem with something weird in my code. If you feel like looking through 217 lines of code here is all the code: http://pastebin.com/YkERYpeF

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T10:51:30+00:00Added an answer on May 20, 2026 at 10:51 am

    Whether !isset($_POST['tosagree']) will be enough depends on the browser.

    To be safe, always set the value attribute of the checkbox. Then, you simply check if that value is present:

    <input type='checkbox' value='agreed'/>
    

    Then do this:

    if (!isset($_POST['tosagree']) || $_POST['tosagree'] != "agreed" ) {
        $errors[] = '<span>Please agree to the Terms of Service.<span>';
    }
    

    Also, when the value attribute is not explicitly specified, browsers will usually set value to On when it is checked.

    Edit

    Ok, I know what’s happening. In your PHP code, you have this block:

    if (!isset($_POST['tosagree']) || $_POST['tosagree'] != "agreed") {//if the user did not agree to ToS
        $errors[] = '<span>Please agree to the Terms of Service.<span>';
    }
    

    Then later you have this line:

    if ($un && $e && $p && $ic) { //if there are no errors
    

    The problem is that you don’t have a flag for when the TOS checkbox isn’t checked. The error can’t be printed because in the if statement you have a call to exit().

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this code that will check the top level checkbox if the checkboxes
i have this code that will check the array contains the specific string and
I have this code that will check for if the class more-results are in
I have this simple code that speaks for itself. <script language='javascript"> function check() {}
Hi I have this code below which is meant to check that the url
I have this code: //check if the user have any previous medical record. var
I have this code here: $('#packageDateStopRenewalCheckedx').bind('check', function(){ $(this).attr('checked', 'checked'); }); $('#packageStatus').live('change', function(){ $('#packageDateStopRenewalCheckedx').trigger('check'); });
I have this code here: $('#packageDateStopRenewalCheckedx').bind('check', function(){ $(this).attr('checked', 'checked'); }); $('#packageStatus').live('change', function(){ $('#packageDateStopRenewalCheckedx').trigger('check'); });
I have this code to get the user name that a friend has messaged
So I have this code that checks 4 parameters (author, title, keyword and subject)

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.