Y
Y
Yuri Elmanov2016-01-29 00:15:32
PHP
Yuri Elmanov, 2016-01-29 00:15:32

PHP add rows to MySQL table?

The essence of the question is this, here is the code, and the table in mysql, when you click on the submit button, the page pretends to send (blinks) and then remains on the same page but with empty forms.
700a87cd3b4c4227bea0a330ff77dc4a.PNG6a6eaee5e67e48a9973414dd93d70969.PNGf470ef537a024d268d9baa28725cf401.PNG

Answer the question

In order to leave comments, you need to log in

3 answer(s)
E
Eugene Mosyukov, 2016-01-29
@Elmanovyurik

The table name must be quoted in the form ` (backtick), not '.
INSERT INTO `vacancies` VALUES ...

A
Aleksey Ratnikov, 2016-01-29
@mahoho

Use prepared statements and bind param , you have mysqli, 2016 is in the yard.

I
Immortal_pony, 2016-01-29
@Immortal_pony

Apostrophes were missing in the string with the mysql query when accessing the elements of the "$_POST" array. Also, it's better to pass NULL rather than an empty string as the value for the incremental id.
It should be something like this:

<?php
mysqli_query($CONNECT, "INSERT INTO 'vacancies' VALUES (NULL, '{$_POST['title']}', '{$_POST['wysiwig-area']}', NOW()");

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question