I wrote the form code:
<form method='post' action='admin.php'> <table width='100%' style='color:white'> <tr><td>Категория:</td></tr> <tr> <td> <select name='category'> <option value='houses'>Участки</option> <option value='clothes'>Одежда</option> <option value='people'>Симы</option> <option value='animals'>Петы</option> <option value='others'>Разное</option> </select> </td> </tr> <tr><td>Название файла:</td><td><input type='text' name='name'></td></tr> <tr><td>Прямая ссылка на файл:</td><td><input type='text' name='link'></td></tr> <tr><td>Описание файла:</td><tr> <tr><td colspan='2'><textarea cols='50' rows='5' name='description'></textarea></td></tr> <tr><td>Скриншот:</td><tr> <tr><td><input type='file' name='image'></td><tr> <tr><td colspan='2'><center><input type='submit' value='Отправить' name='submit' class='button'></center></td></tr> </table> </form>
Now in my select, each option has value = 'houses', etc. etc. Treatment...
if (@$_POST['submit']) { $bd="bd/".$_POST['category'].".dat"; $name = $_POST['name']; $link = $_POST['link']; $description = $_POST['description']; $name = htmlspecialchars($name); $link = htmlspecialchars($link); $description = htmlspecialchars($description); if (!empty($name) && !empty($link) && !empty($message)) { $path = "images/fileimages/"; $tempfile = $_FILES['image']['tmp_name']; $newname = $path . "/" . $_FILES['image']['name']; $img = $_FILES['image']['name']; if (is_uploaded_file($tempfile)) { copy($tempfile, $newname); } $text = "$name:::$link:::$description:::$img"; $fh = fopen($bd, "a"); fwrite($fh, "$text\n"); fclose($fh); } }
I need that when choosing from select
, for example, “Sections”, the value of houses
, etc., is written to $bd
, but this does not happen, because nothing is added to the file. Help me please.