frankienrg Posted May 22, 2012 Share Posted May 22, 2012 The Form: <form action="pagina5.php" method="post"> <table align="center" width="500"> <tr><td align="right">Nome:</td><td><input type="text" maxlength="35" size="35" name="nome" /><td></tr> <tr><td align="right">E-mail:</td><td><input type="text" maxlength="40" size="35" name="email" /><td></tr> <tr><td align="right">Voto:</td><td><select name="voto"><option value="1">1</option><option value="2">2</option><option value="3">3</option><option value="4">4</option><option selected="selected" value="5">5</option></select><td></tr> <tr><td align="center" colspan="2"> *Commento:</td></tr> <tr><td align="center" colspan="2"><textarea rows="7" cols="50" name="commento"></textarea></td></tr> <tr><td align="center" colspan="2"><input type="submit" name="invia" value="Invia"><input type="reset" value="Resetta"></td></tr> <tr><td align="center" colspan="2"><a href="gb.php">Torna Indietro</a></td></tr> <tr><td align="center" colspan="2"><br/><br/>* = Campi Obbligatori</td></tr> </table> </form> the script (pagina5.php): <? if (isset($_POST['invia'])) { if((!isset($_POST['commento'])) OR ($_POST['commento']="")) { echo "<p align='center'>Non hai compilato i campi richiesti!</p>"; echo "<p align='center'><br/><a href='gb.php'>Torna Indietro</a></p>"; } else { var_dump($_POST['nome']); var_dump($_POST['email']); var_dump($_POST['commento']); var_dump($_POST['voto']); //var_dump($x); echo "<p align='center'><br/><a href='gb.php'>Torna Indietro</a></p>"; } } ?> vardumps work correctly for any value except the textarea (commento). It skips the if (!isset) check, too. I tried using an ID, too, couldn't get it to work I'm at a lost here, please help, fellow coders. Quote Link to comment https://forums.phpfreaks.com/topic/262943-problem-with-php-and-forms-textarea-_post-not-returning-values/ Share on other sites More sharing options...
mrMarcus Posted May 22, 2012 Share Posted May 22, 2012 You are not using a comparison operator when checking $_POST['commento'] = "". Instead, you are emptying it. Change if((!isset($_POST['commento'])) OR ($_POST['commento']="")) to* if (!isset($_POST['commento']) || empty($_POST['commento'])) *just cleaned it up a bit, too. However, this is the correction to your original issue: if((!isset($_POST['commento'])) OR ($_POST['commento']=="")) Note the == which is checking if $_POST['commento'] is of any length. Quote Link to comment https://forums.phpfreaks.com/topic/262943-problem-with-php-and-forms-textarea-_post-not-returning-values/#findComment-1347705 Share on other sites More sharing options...
frankienrg Posted May 22, 2012 Author Share Posted May 22, 2012 Gee, I was going mad. Such a stupid mistake. Lost a good 2hours of work! THANK YOU! Problem solved! Quote Link to comment https://forums.phpfreaks.com/topic/262943-problem-with-php-and-forms-textarea-_post-not-returning-values/#findComment-1347707 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.