Jump to content

Recommended Posts

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.

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.