S
S
SVML2018-04-18 07:15:20
PHP
SVML, 2018-04-18 07:15:20

Why does the handler not enter this data into the MY SQL database?

<html>
 <?
 include("connect.php")
 ?>
<head><title>Принтер</title></head>
<link href="style1.css" rel="stylesheet">
<header>
<div id="HeaderText">
Принтер
</div>
</header>
<body>
<form  name="forma" action="add.php" method="post">
<div align="center">
<p id="block">
<select name="wp" id="oshibka" style="width:60%;height:10%;">
  <option disabled selected >Выберите пункт</option>
  <option>Не отправляет на печать</option>
  <option>Закончилась краска</option>
  <option>Застряла бумага</option>
</select>

  <input name="kp" id="comment"
  placeholder="Введите комментарий" value=""
style="width:60%;height:10%;"></input>

<button id="Zprin" type="submit"
style="width:60%;height:25%;" 
  value="Отправить заявку">Отправить заявку</button>
  
   <input name="polzovatel" 
  placeholder="Введите пользователя" value=""
style="width:60%;height:10%;"></input>
   <input name="prichina"
  placeholder="Введите оборудование" value=""
style="width:60%;height:10%;"></input>
  </p>
  </div>
  </form>
</body>
</html>

<?php
include ("connect.php");
$prichina=$HTTP_POST_VARS['prichina'];
$oshibka=$HTTP_POST_VARS['oshibka'];
$polzovatel=$HTTP_POST_VARS['polzovatel'];
$comment=$HTTP_POST_VARS['comment'];
$result = mysql_query("INSERT INTO Zayavka (polzovatel, prichina, oshibka, comment) VALUES ('$polzovatel', '$prichina', '$oshibka', '$comment')");

if($result == 'true')

{echo "Ваши данные успешно добавлены";}

else {echo "Ваши данные не добавлены";}
?>

Writes that "data added successfully", but only ID-autocomplete is added to the table, the rest of the columns are empty

Answer the question

In order to leave comments, you need to log in

3 answer(s)
R
Rsa97, 2018-04-18
@SVML

From forms, field values ​​are passed by the 'name' attribute, not the 'id' attribute.
And throw away your textbook, in PHP 7.0 and above the mysql_ functions have already been removed. Use PDO or mysqli.

V
Vlad Nevlad, 2018-04-18
@vladnevlad

epidemic is direct any Why the data in a DB is not written down??

A
Alexander Razumov, 2018-04-18
@razumovsu

And for the future. In real projects, don't accept raw data from superglobals. Either use an ORM where the data is properly "prepared" for writing, or use prepared queries to protect against SQL injections

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question