HI,

I am a beginner at programing and I have to do this project where it is asking me to validate any ISBN 13 number. I know how to set up the input page, but I am having or you could say no Idea how to validate a number if user inputs data in the input page. I have some code below that I think it should be included, but if someone has better way to do it then I would be appreciate it.

here is the input page code:

<form method="POST" action="Process_isbn13.php">

<p>Enter the ISBN 13: <input type="text" name="isbn13"/></p>

<input type="submit" name="Submit" value="Submit" />

</form>

I have this so far for my processing page to validate the ISBN 13 number!

<?php

function isValidISBN13($isbn)
{
    $sum = 0;
    for ($i = 0; $i < 13; $i++)
    {
        if ($isbn[$i] === 'X')
        {
            $value = 13;
        }
        else
        {
            $value = $isbn[$i];
        }

        $sum += ($i + 1) * $value;
    }
}

?>

I know there should be more like if it is empty it should say it's empty do it again and if it is not validate then it would say that.

The most important thing I need is the code so if i enter a validate ISBN 13 number it would say it's validate!

Someone please help me with the code needed to check if ISBN 13 number is validate.

Recommended Answers

All 5 Replies

Isn't this just an extension of ...

Indeed, just need to add recalculation of the check digit.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.