What's wrong with my code. It display the followin error message in the drop-down field:
Fatal error: Call to undefined function option_selected() in PHP in C:\xampp\htdocs\imageconcert/index.php on line 27
Here's the code:
<?php
if (isset($_GET["target"]))
{
function option_selected($target, $value)
{
$v=$_POST[$target];
if ($v == $target)
{
$selected="selected";
}
echo $selected;
}
}
?>
<html>
<head>
<body>
<h1>Ezen az oldalon JPEG, PNG, BMP vagy GIF fájlt tudsz konverálni!</h1>
<form action="function.php" method="post" enctype="multipart/form-data">
Forrás fájl (jpeg,png,bmp vagy gif, max. 2MB):
<input type="file" name="file" value="file" />
<br />
<br />
Célfájl formátuma
<select id="target" name="target">
<option value="JPEG"><?php echo option_selected("target", "JPEG"); ?>> JPEG </option>
<option value="JPG"> <?php echo option_selected("target", "JPE"); ?>> JPG </option>
<option value="BMP"> <?php echo option_selected("target", "BMP"); ?>> BMP </option>
<option value="GIF"> <?php echo option_selected("target", "GIF"); ?>> GIF </option>
<option value="PNG"> <?php echo option_selected("target", "PNG"); ?>> PNG </option>
</select>
<br />
<br />
<input type="submit" name="Elküldés" value="Konvertálás"/>
</form>
</body>
</head>
</html>