Search code examples
phphtmlemailgetisset

functions gets the value true even when there is no value


i am traing to send a mail with php and i wrote this:

<?php
function title()
{
if(isset($_GET['title']))
{
    return true;
}
else
{
    echo "please write a title!";
    return false;
}
}

function mess()
{
if(isset($_GET['mess']))
{
    return true;
}
else
{
    echo "please write a messege!";
    return false;
}
}

if(mess() && title())
{
    mail("[email protected]", $_GET['title'], $_GET['mess']);
    echo "the mail has bees send!";
}

?>
<form action="ftp_mail.php" method="get">
the title:
<input type="text" name="title"  />
the messege:
<input type="text" name="mess" />
<input type="submit" value="send" />
</form>

but even when i doesn't writing anything on $_GET['mess'] and $_GET['title'] the functions mess() and title() gets the value true. please help!!


Solution

  • Use this

    if((isset($_GET['mess'])) && ($_GET['mess']!=""))