So I have a select in a form...
<select id="aca" name="aca">
<option value="2012">2012-2013</option>
<option value="2011">2011-2012</option>
<option value="2010">2010-2011</option>
<option value="2009">2009-2010</option>
<option value="2008">2008-2009</option>
<option value="2007">2007-2008</option>
<option value="2006">2006-2007</option>
<option value="2005">2005-2006</option>
</select>
Looks good, right ? Then I want to check if the whole form is set:
if(isset($_FILES['fichier']) && isset($_POST['nom']) && isset($_POST['a']) && isset($_POST['c']) && isset($_POST['t']) && isset($_POST['auteur']) && isset($_POST['aca'])) echo 'tout';
Well this always return FALSE, and I know it's due to 'aca'. When I try...
if(isset($_POST['aca'])) echo 'aca';
It returns TRUE if I selected something in the list, and the other condition still doesn't echo 'tout', so I just see 'aca'. And this js line doesn't seem to be the problem as other select's return TRUE.
$("select").prop('selectedIndex', -1);
I really don't understand... HALP ^^"
Full HTML:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Upload</title>
<link rel="stylesheet" href="style/upload.css"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script src="js/upload.js"></script>
</head>
<body>
<form method="post" action="" enctype="multipart/form-data">
<fieldset>
<legend>Informations d'upload</legend>
<p>Fichier (tous formats | max. 1 Mo):</p>
<input type="file" name="fichier" size="60"/><br/>
<p>Nom du fichier. Caractères utilisables: alphanumériques °*@()-_()</p>
<input type="text" name="nom" size="40"/>
</fieldset>
<fieldset>
<legend>Classification</legend>
<p>Merci d'indiquer où ce fichier devra être classé.</p>
<select id="a" name="a">
<option value="0">BA1</option>
</select>
<select id="c" name="c" style="display:none"></select>
<select id="t" name="t" style="display:none"></select>
</fieldset>
<fieldset>
<legend>Détails</legend>
<p>Auteur:</p>
<input type="text" name="auteur" size="40"/>
<p>Année académique:</p>
<select id="aca" name="aca">
<option value="2012">2012-2013</option>
<option value="2011">2011-2012</option>
<option value="2010">2010-2011</option>
<option value="2009">2009-2010</option>
<option value="2008">2008-2009</option>
<option value="2007">2007-2008</option>
<option value="2006">2006-2007</option>
<option value="2005">2005-2006</option>
</select>
</fieldset>
<br/>
<div style="width:500px;text-align:center">
<input type="submit" name="submit" value="Envoyer" />
</div>
</form>
</body>
</html>
Full PHP:
<?php
$formats = array('pdf');
echo strtolower(substr(strrchr($_FILES['fichier']['name'],'.'),1)).'<br/>';
if(isset($_POST['aca'])) echo 'aca';
if(isset($_FILES['fichier']) && isset($_POST['nom']) && isset($_POST['a']) && isset($_POST['c']) && isset($_POST['t']) && isset($_POST['auteur']) && isset($_POST['aca'])) echo 'tout';
if(preg_match("#^[a-zA-Z0-9éè°*@ ()_-]{10,50}$#",$_POST['nom']))
{
echo 'OK';
}
else echo 'Nope';
?>