R
R
Roman Sergeev2017-06-11 11:58:08
Database
Roman Sergeev, 2017-06-11 11:58:08

Sending form data to the database. What is the problem?

How to make sure that data is not sent to one table in the database, but to different ones?
At me only in two tables it turned out to make! But you need to make sure that the names of the desired tables are found in the field and send it like that. I don’t understand how

<div class="editor-form-block">
      <h2>Числитель</h2>
      <form action="" method="POST">
        <input class="pole" name="day" type="text" required placeholder="День недели"> <br> 
        <input class="pole" name="subject" type="text" required placeholder="Предмет"> <br>       
        <input class="pole" name="classroom" type="text" required placeholder="Аудитория"> <br>
        <input class="pole" name="teacher" type="text" required placeholder="Преподователь"> <br>
        <input class="submit2" name="submit"  type="submit" value="Сохранить"> 
      </form>
      <?php
        $day = mysql_real_escape_string(htmlspecialchars($_POST['day']));
        $subject = mysql_real_escape_string(htmlspecialchars($_POST['subject']));
        $classroom = mysql_real_escape_string(htmlspecialchars($_POST['classroom']));
        $teacher = mysql_real_escape_string(htmlspecialchars($_POST['teacher']));
        if (isset($_POST['submit'])) {
          mysql_query("INSERT INTO `pks13` (`day`, `subject`, `classroom`, `teacher`) VALUES ('$day', '$subject', '$classroom', '$teacher')");
        }  
      
      ?>
    </div>
    <div class="editor-form-block">
      <h2>Знаменатель</h2>
      <form action="" method="POST">
        <input class="pole" name="day" type="text" required placeholder="День недели"> <br> 
        <input class="pole" name="subject" type="text" required placeholder="Предмет"> <br>       
        <input class="pole" name="classroom" type="text" required placeholder="Аудитория"> <br>
        <input class="pole" name="teacher" type="text" required placeholder="Преподователь"> <br>
        <input class="submit2" name="submit"  type="submit" value="Сохранить"> 
      </form>
      <?php
        $day = mysql_real_escape_string(htmlspecialchars($_POST['day']));
        $subject = mysql_real_escape_string(htmlspecialchars($_POST['subject']));
        $classroom = mysql_real_escape_string(htmlspecialchars($_POST['classroom']));
        $teacher = mysql_real_escape_string(htmlspecialchars($_POST['teacher']));
        if (isset($_POST['submit'])) {
          mysql_query("INSERT INTO `denominator_pks13` (`day`, `subject`, `classroom`, `teacher`) VALUES ('$day', '$subject', '$classroom', '$teacher')");
        }  
      
      ?>
    </div>

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question