Hello! I can not understand. It is necessary that when selecting </option> , for example, history is checked for another condition, the $predmet variable is then compared and, if it is, the data is entered into the $page variable.

 <? if ($predmet='history') {($page='vistor');} if ($predmet='english') {($page='rus');} ?> <form action="add.php" method="post" name="form"> <select name="predmet" id="predmet"> <option>history</option> <option>english</option> <input name="page" type="hidden" value="<? echo $page;?>" /> <p> <input name="add" type="submit" value="Добавить" /></p> </form> 

    2 answers 2

     <? if ($_POST['predmet']=='history') {($page='vistor');} if ($_POST['predmet']=='english') {($page='rus');} ?> <form action="add.php" method="post" name="form"> <select name="predmet" id="predmet"> <option value="history">history</option> <option value="english">english</option> </select> <input name="page" type="hidden" value="<?=$page;?>" /> <p> <input name="add" type="submit" value="Добавить" /></p> </form> 

    Well, this is all in one file should be - add.php

    It would be good to learn some html markup, solid errors!

    and in general it is not clear that this piece of code generally does, butter.

    • if ($ predmet = 'history') {($ page = 'vistor');} - this is my wrong condition ...... if ($ _POST ['predmet'] == 'history') {($ page = 'vistor');} - this is my decision, thanks to you Shrek! - Izet
    • please - Artem

    double equals (==), but not (=) most likely should be used, but generally format the code

    • wrap <input /> in <p> IMHO moveton. Is it harmful to wrap the assignment in brackets? ($page='value') Is it all one file? where does $predmet ? backfill: <select> - has a closing tag. - ikoolik
    • sorry <select> - of course it has a closing tag - Izet