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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T06:22:31+00:00 2026-05-30T06:22:31+00:00

This is probably really dirty and messy code, so any input on that would

  • 0

This is probably really dirty and messy code, so any input on that would be helpful as well, but my main issue is that I can’t get the “ISBN” input to process if the string is the correct number of characters (10 or 13). I’m not sure where it is going wrong. It’s on line 64.

Please help! Thank you.

<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Link Generator</title>
</head>

<body>
    <?php

        function showForm() {

            if (empty($_POST['title'])) {
                $title = "Book Title";
            } else {
                $title = $_POST['title'];
            }
    ?>

    <form action="<?php $_SERVER['PHP_SELF'] ?>" method="post">

        Search by ISBN<br />
        <input type="text" maxlength="13" name="ISBN" size="30" value="ISBN" onblur="if(this.value == '') { this.value='ISBN'}" onfocus="if (this.value == 'ISBN') {this.value=''}" /><br />

        <br />OR<br /><br />

        Search by Title <strong>and</strong> Author<br />
        <input type="text" maxlength="13" name="title" size="30" value="<?php echo $title; ?>" onblur="if(this.value == '') { this.value='Book Title'}" onfocus="if (this.value == 'Book Title') {this.value=''}" /><br />
        <input type="text" maxlength="13" name="aname" size="30" value="Author Name" onblur="if(this.value == '') { this.value='Author Name'}" onfocus="if (this.value == 'Author Name') {this.value=''}" /><br />

        <br /><input type="submit" name="submit" value="Generate Link" />

    </form>

    <?php

        }

        function generateLink_ISBN() {
            echo "Your link has been generated:<br />";
            echo "http://xxx.com/uhtbin/cgisirsi.exe/x/0/0/5?search_type=search&searchdata1=" . $_POST['ISBN'] . "&library=ALL&sort_by=PBYR";   
        }

        function generateLink_title() {
            echo "Your link has been generated:<br />";
            echo "http://xxx.com/uhtbin/cgisirsi.exe/x/0/0/5?search_type=search&searchdata1=" . $_POST['title'] . "+" . $_POST['aname'] . "&library=ALL&sort_by=PBYR";  
        }

        if(isset($_POST['submit'])) {

            if (isset($_POST['ISBN']) && isset($_POST['title']) && isset($_POST['aname']) && ($_POST['ISBN'] == 'ISBN') && ($_POST['aname'] == 'Author Name') && ($_POST['title'] == 'Book Title')) {

                echo "<h1>You did not input any information</h1>";
                showForm();

            } elseif (isset($_POST['ISBN']) && ($_POST['ISBN'] != 'ISBN')) {

                if (isset($_POST['ISBN']) && ($_POST['ISBN'] != 'ISBN') && (!is_numeric ($_POST['ISBN']))) {

                     echo "<h1>The ISBN you entered did not contain all numerics</h1>";
                     showForm();

                } elseif (isset($_POST['ISBN']) && ($_POST['ISBN'] != 'ISBN') && ((mb_strlen($_POST['ISBN'], 'utf-8') != 13) | (mb_strlen($_POST['ISBN'], 'utf-8') != 10))) {

                    echo "<h1>The ISBN you entered was too long or too short. ISBN's are 10 or 13 numbers in length.</h1>";
                    showForm();

                } else  {

                    generateLink_ISBN();

                }

            } elseif (isset($_POST['title']) && isset($_POST['aname']) && ($_POST['aname'] != 'Author Name') | ($_POST['title'] != 'Book Title')) {

                if (isset($_POST['title']) && isset($_POST['aname']) && ($_POST['title'] == 'Book Title') && ($_POST['aname'] != 'Author Name')) {

                    echo "<h1>To search by author's name, you must also include the book title.</h1>";
                    showForm();

                } elseif (isset($_POST['title']) && isset($_POST['aname']) && ($_POST['aname'] == 'Author Name') && ($_POST['title'] != 'Book Title')) {

                    echo "<h1>To search by book title, you must also include the author's name.</h1>";
                    showForm();

                } else {

                    generateLink_title();

                }

            } else {

                showForm(); 

            }

        } else {

            showForm(); 

        }

    ?>

</body>

  • 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-30T06:22:32+00:00Added an answer on May 30, 2026 at 6:22 am

    This always evaluates to true:

    ((mb_strlen($_POST['ISBN'], 'utf-8') != 13) | (mb_strlen($_POST['ISBN'], 'utf-8') != 10))
    

    You’re saying “if ISBN isn’t 13 characters long or ISBN isn’t 10 characters long, then true”. But no string can be both 13 characters and 10 characters.

    Try this instead:

    !((mb_strlen($_POST['ISBN'], 'utf-8') == 13) | (mb_strlen($_POST['ISBN'], 'utf-8') == 10))
    

    Which would be “if it is not the case that either ISBN is 13 characters or ISBN is 10 characters, then true”.

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

Sidebar

Related Questions

This is probably really stupid but i can't find the problem with my code.
Now this is probably really easy but being the tool that I am, I'm
I know this probably really simple but Im not sure what im doing wrong...
This probably sounds really stupid but I have noo idea how to implement jquery's
This is probably really easy but I can't seem to figure out how to
This is probably really easy, but I'm lost on how to make sure it
I know this is probably really obvious, but I cannot figure out why I
This is probably a really simple jQuery question, but I couldn't answer it after
This is probably a really stupid newbie-sounding question to you developer type people, but
This is probably a really stupid MSBuild question but if I have <ItemGroup> <Dll

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.