May I have someone's suggestion as to how to prevent PHP from reporting the following message:
Notice: Undefined index: cobrand in c:\inetpub\wwwroot\test.php on line 5
cobrand is empty
...when the code below is executed?
Thanks everyone.
Lester
///////////////////////////////////////////
<?php
$myform = $_SERVER['PHP_SELF'];
$formsent = $_GET['formsent'];
$cobrand = $_GET['cobrand'];
$theform = "
<form action=\"$myform\" method=\"get\">
<select name=\"cobrand\">
<option>mybrand1</option>
<option>mybrand2</option>
</select>
<input type=\"submit\">
<input type=\"hidden\" name=\"formsent\" value=\"true\">
</form>
";
///////////////////////////////////////////
if(isset($formsent))
{
echo "cobrand is $cobrand";
echo "formsent is $formsent";
}
else
{
echo "cobrand is empty";
}
print $theform;
?>
Suggestion for resolving undefined index
Moderator: General Moderators
try
Code: Select all
if (isset($_GET['cobrand'])){
$cobrand = $_GET['cobrand'];
}-
kettle_drum
- DevNet Resident
- Posts: 1150
- Joined: Sun Jul 20, 2003 9:25 pm
- Location: West Yorkshire, England
read this - http://www.devnetwork.net/forums/viewtopic.php?t=21171techlinks wrote:To lostboy or others...how did you do accomplish the color formatting on the code with your response? Just curious.