I have a web form that takes 2 string values and 2 integer values from a user and stores them in a database.
How can I ensure that the ints are actually ints and sanitze input so that Bobby Tables doesn't pay me a visit?
Here is my forms code:
if(isset($_POST['submit']))
{
$formTitle = $_POST['title'];
$formAuthor = $_POST['author'];
$formPagecount = $_POST["pagecount"];
$formCurrentpage = $_POST["currentpage"];
}
<form method="post" action="index.php">
Title: <input type="text" size="25" maxlength="250" name="title" />
<br/>
Author: <input type="text" size="25" maxlength="250" name="author" />
<br/>
Page Count: <input type="text" size="25" maxlength="25" name="pagecount" />
<br/>
Current Page: <input type="text" size="25" maxlength="25" name="currentpage" />
<br />
<input type="submit" value="Add new book" name="submit" />
</form>