Hi Guys,
Can someone please tell me why no echo statements work after my heredoc :?
Here's the code:
<?php
switch($_POST['options']){
case '1':
$selected1 = 'selected';
break;
case '2':
$selected2 = 'selected';
break;
case '3':
$selected3 = 'selected';
break;
case '4':
$selected4 = 'selected';
break;
default:
$selected1 = $selected2 = $selected3 = $selected4 = '';
}
echo <<<END
<html>
<head>
<script type="text/javascript">
function show_alert()
{
alert("I am an alert box!");
}
function formSubmit()
{
document.getElementById("frm1").submit();
}
</script>
</head>
<body>
<form id="frm1" method="post" action="search.php" />
<select onclick="formSubmit()" name="options" size="1">
<option $selected1 value="1">date</option>
<option $selected2 value="2">year</option>
<option $selected3 value="3">country</option>
<option $selected4 value="4">language</option>
</ select>
</body>
</html>
</form>
END;
if(isset($_POST['options'])){
echo "item chosen";
}
It works when I put the 'isset' if clause before the heredoc and even weirder, if i add a submit input type in the form as the last field it works as is? ex:
<?php
switch($_POST['options']){
case '1':
$selected1 = 'selected';
break;
case '2':
$selected2 = 'selected';
break;
case '3':
$selected3 = 'selected';
break;
case '4':
$selected4 = 'selected';
break;
default:
$selected1 = $selected2 = $selected3 = $selected4 = '';
}
echo <<<END
<html>
<head>
<script type="text/javascript">
function show_alert()
{
alert("I am an alert box!");
}
function formSubmit()
{
document.getElementById("frm1").submit();
}
</script>
</head>
<body>
<form id="frm1" method="post" action="search.php" />
<select onclick="formSubmit()" name="options" size="1">
<option $selected1 value="1">date</option>
<option $selected2 value="2">year</option>
<option $selected3 value="3">country</option>
<option $selected4 value="4">language</option>
<input type="submit">
</ select>
</body>
</html>
</form>
END;
if(isset($_POST['options'])){
echo "item chosen";
}
Any help would be greatly appreciated!
Cheers
D