I try to create a query getting from a formular through post function. The post function must pass a text and an int variable to create the query sent to database.
When I start execute my php script, it says: undefined index, for the int variable.
I dont understand why the int variable isn't recognized. here is my code:
formulaire04.php
<form action="selection_jeux.php" method="post">
<p>
Nom
<input type="text" name="possesseur"/>
Prix maximum
<input type="int" name="prixmax"/>
<input type="submit" value="Valider"/>
</p>
</form>
selection_jeux.php
<?php
try
{
$bdd = new PDO('mysql:host=localhost;dbname=test' , 'root', '');
}
catch(Exception $e)
{
die('Erreur : '.$e->getMessage());
}
$req = $bdd->prepare('SELECT nomselec, prix FROM jeux_video WHERE possesseur = :possesseur AND prix <= :prixmax');
$req->execute(array('possesseur'=> $_POST['possesseur'], 'prixmax'=> $_POST['prixmax']));
echo '<ul>';
while($donnees = $req->fetch())
{
echo '<li>' . $donnees['nom'] . ' (' . $donnees['prix'] . ' EUR)</li>';
}
echo '<li>';
$req->closeCursor();
?>
intisn't a valid value for thetypeattribute of an HTML<input>element.