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 8302753
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T17:21:47+00:00 2026-06-08T17:21:47+00:00

As I was working with my program, I had come up with an unknown

  • 0

As I was working with my program, I had come up with an unknown error. What happens is that my code is bypassing two if statements. Here’s my code:

<?
session_start();
if ($_POST){
  $ao = trim($_POST['amountof']);
  $continue = true;
  if (strlen($ao) < 1){  ####First If-Statement Bypassed####
    $continue = false;
    $_SESSION['error'] = "Please enter in a value!";
  }
  if (strlen($ao) > 20){  ####Second If-Statement Bypassed####
    $continue = false;
    $_SESSION['error'] = "Your value has exceeded 20!";
  }
  if (!is_numeric($ao)){
    $continue = false;
    $_SESSION['error'] = "Value is not numeric!";
  }
}

?>
<form method="post">
<?
if (isset($_SESSION['error'])){
  print "<span style=\"color: red; font-weight: bold;\">" . $_SESSION['error'] . "                </span><br />";
}
?>
How many letters are you planning to process?<br />
<span style="font-size:.8em; color: grey;">You may not exceed 20</span><br />
<input type="text" name="amountof" style="width:25px;" maxlength="2"/>
<input type="submit" value="Continue" />
</form>

<? unset($_SESSION['error']); ?>

The if statements that are bypassed are marked in the code.
Thank you!

  • 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-06-08T17:21:49+00:00Added an answer on June 8, 2026 at 5:21 pm

    Try that:

    <?php
    
     session_start();
     $_SESSION['error']='';
    
      if (isset($_POST['amountof'])){
      $ao = trim($_POST['amountof']);
      $continue = true;
      if (strlen($ao) < 1){ 
        $continue = false;
        $_SESSION['error'].= "Please enter in a value!<br/>";
      }
    
      if (!is_numeric($ao)){
        $continue = false;
        $_SESSION['error'].= "Value is not numeric!<br/>";
      }
      elseif ($ao > 20){ 
        $continue = false;
        $_SESSION['error'].= "Your value has exceeded 20!";
      }
    }
    ?>
    <form method="post">
    <?php
     if (!empty($_SESSION['error'])){
    
     //......
    

    or simplified(note that the user may type negative values or 0 what currently will pass the test)

    if (!is_numeric($ao) || $ao<1 || $ao>20){
            $continue = false;
            $_SESSION['error']= "Please enter in a numeric value between 1 and 20";
          }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm currently working on an a program idea I've had that involves desktop remoting.
I have a working program in C++ that generates data for a Mandelbrot Set.
I was working on a program today and hit this strange bug. I had
I'm working on a program for class that involves solving the Chinese Postman problem
A while back, I was working on a program that hashed values into a
My program has been working perfectly so far, but it turns out that I've
I've been working on a program that is supposed to output the winning status
I'm working on a program that generates an FDF file for filling in an
I’m having some strange problem with my JS program. I had this working properly
I had a program working with a database I created using SQL Server Compact

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.