Unable to insert data into Mysql from a materialized modal form

妖精的绣舞 提交于 2019-12-23 01:02:05

问题


Same code works for normal form but not for modal form. Cannot understand why.

Below is one of the modals that I am using in my admin dashboard. Currently it has only one field in the form. But when I try to submit the form, the modal closes but data is not inserted into database and also it is not displaying any error. Following is the code for Modal and Form.

    <li><a href="#modal1" class="tooltipped modal-trigger" data-position="bottom" data-delay="50" data-tooltip="Update Events"><i class="material-icons">announcement</i></a></li>

         <div id="modal1" class="modal">

            <div class="modal-content ">
               <div class="row">

                <form class="col s12" action="updatetext.php" method="POST">
                  <div class="row">
                    <div class="input-field col s12">

                      <!-- <i class="material-icons prefix">mode_edit</i> -->
                      <textarea id="icon_prefix2" class="materialize-textarea" style="color:#000"></textarea>

                      <label for="icon_prefix2" >News</label>
                      <input type="text" name="news">
                    </div>
                  </div>
                 <input type="submit" value="submit" class="modal-action modal-close waves-effect waves-green btn-flat ">
                 <a name="submit" class="modal-action modal-close waves-effect waves-green btn-flat ">Update</a>
                 <a class="modal-action modal-close waves-effect waves-green btn-flat ">Cancel</a>
                 </div>
                </form>
              </div>
            </div>

This is the code for updatetext.php

<?php


include_once("db.php"); 
error_reporting(E_ALL);
ini_set('display_errors', 1);

if(isset($_POST["submit"])) {

    $news = $_POST['news'];

    $news = mysqli_real_escape_string($conn, $news);

    $query = mysqli_query($conn, "INSERT INTO news (newsmatter) VALUES ('$news')"); 


   }
   ?>

来源:https://stackoverflow.com/questions/37811287/unable-to-insert-data-into-mysql-from-a-materialized-modal-form

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!