I am making picture albums site. In this site, user enters the name of album first then description at very next page. Name of the album works good but then when user goes on description page this line appears on page
Notice: Undefined index: albumdescription in C:\wamp\www\createalbum.php on line 12
but it works fine. I changed this line
$albumdescription = $_POST['albumdescription'];
with this
$albumdescription = isset($_POST['albumdescription']);
the error line disappear but when I go back to albums page it shows album description "1"
code is given below
<?php
$id = isset($_POST['id']);
$albumname = $_POST['albumname'];
$email = $_SESSION['email'];
$albumdescription = $_POST['albumdescription'];
if ($albumdescription)
{
if (strlen($albumdescription)>100)
echo "Description is too long.";
else
{
$create = mysql_query ("INSERT into albums VALUES ('','$id','$email','$albumname','$albumdescription','0','images/nocover.jpg')");
echo "Album Created !";
}
}
if($albumname&&!$albumdescription)
{
if (strlen($albumname)>20)
echo "Albumname too long";
else
{
echo "
<table cellpadding='7' width='100%'>
<tr>
<td>
<font size='2' face='arial'>
Please give a description to album <b>$albumname</b>
<form action='createalbum.php' method='POST'>
<textarea name='albumdescription' maxlength='100'></textarea>
<input type='submit' name='submit' value='Create'>
<input type='hidden' name='albumname' value='$albumname'>
</form>
</td>
</tr>
</table>
";
}
}
?>
</html>
Notice: Undefined index: albumdescription in C:\wamp\www\createalbum.php on line 12
but it works fine. I changed this line
$albumdescription = $_POST['albumdescription'];
with this
$albumdescription = isset($_POST['albumdescription']);
the error line disappear but when I go back to albums page it shows album description "1"
code is given below
<?php
$id = isset($_POST['id']);
$albumname = $_POST['albumname'];
$email = $_SESSION['email'];
$albumdescription = $_POST['albumdescription'];
if ($albumdescription)
{
if (strlen($albumdescription)>100)
echo "Description is too long.";
else
{
$create = mysql_query ("INSERT into albums VALUES ('','$id','$email','$albumname','$albumdescription','0','images/nocover.jpg')");
echo "Album Created !";
}
}
if($albumname&&!$albumdescription)
{
if (strlen($albumname)>20)
echo "Albumname too long";
else
{
echo "
<table cellpadding='7' width='100%'>
<tr>
<td>
<font size='2' face='arial'>
Please give a description to album <b>$albumname</b>
<form action='createalbum.php' method='POST'>
<textarea name='albumdescription' maxlength='100'></textarea>
<input type='submit' name='submit' value='Create'>
<input type='hidden' name='albumname' value='$albumname'>
</form>
</td>
</tr>
</table>
";
}
}
?>
</html>