Представление не подтверждено HTML PHP - PullRequest
0 голосов
/ 04 сентября 2018

У меня есть форма с кнопкой отправки в HTML: -

  <div style="display: flex;">
         <form name="myform"method="post" action="usdbtc.php" style="float:left;">
                <div id="log_err"> <strong><?php if(isset($logerror)) { echo $logerror; } else { $dn = 'dn'; } ?></strong> </div>   
                    <p><label style="float: left;">Price:</label><input class="input101" style="float: left;" type="text" name="username" id="box1" oninput="calculate()"><label style="float: right;">: BTC</label><input class="input101" style="float: right;" type="text" name="username" id="box2" oninput="calculate()">
                     <br><input class="input101" style="float: right;" type="text" name="username" id="result"><br><label style="padding: 10px;">Total BTC:</label>
                <td rowspan="2">
                    <input type="hidden" id="myform" value="1"/>
                        <br><span class="orderbutton" type="submit" id="ordersell" onclick="myform.submit()">SELL</span></p>
                    </td>

            </form>
            <form name="yourform"method="post" action="usdbtc.php" style="float:right;">
                    <p><label style="float: left;">Price:</label><input class="input101" style="float: left;" type="text" name="username" id="box3" oninput="calculate()"><label style="float: right;">: BTC</label><input class="input101" style="float: right;" type="text" name="username" id="box4" oninput="calculate()">
                     <br><input class="input101" style="float: right;" type="text" name="username" id="resul"><br><label style="padding: 10px;">Total BTC:</label>
                <td rowspan="2">
                    <input type="hidden" id="yourform" value="1"/>
                        <br>
                        <span class="orderbutton" type="submit" id="orderbuy" onclick="yourform.submit()">BUY</span></p>
                    </td>

            </form>
            </div>

И чтобы проверить, нажал ли пользователь кнопку «ПРОДАВАТЬ» в php: -

  if($_POST['myform']){
 echo 'yes'; 
 }
 else {
  echo 'no';
 }

Я всегда получаю сообщение "нет" после нажатия кнопки, есть ли что-то неправильное, что я кодировал в части HTML или PHP? Помощь приветствуется .. Я просто хочу получить часть для php

 if($_POST['?']) {...

Помните, что на странице есть две формы, каждая из которых имеет имя и скрытый идентификатор ввода.

1 Ответ

0 голосов
/ 04 сентября 2018
<input type="hidden" id="myform" value="1"/>

Изменить атрибут id на имя

<input type="hidden" name="myform" value="1">

И в теге формы отсутствует пробел

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...