Answer the question
In order to leave comments, you need to log in
Why is the data not being written to the database??
Here is the code where the user writes data
<li><p align="right"><label id="label-name">Имя<span>*</span></label><input maxlength="15" type="text" id="name_review" /></p></li>
<li><p align="right"><label id="label-good">Достоинства<span>*</span></label><textarea id="good_review"></textarea></p></li >
<li><p align="right"><label id="label-bad">Недостатки<span>*</span></label><textarea id="bad_review"></textarea></p></li>
<li><p align="right"><label id="label-comment">Комментарий</label><textarea id="comment_review"></textarea></p></li>
<p id="reload-img"><img src="../ring.gif" /></p> <p id="button-send-review" iid="'.$post_id.'">Отправить</p>
if($_SERVER["REQUEST_METHOD"] == "POST"){
include("connect_db.php");
$id = clear_string($_POST['id']);
$name = iconv ("UTF-8", "cp1251" , clear_string($_POST['name']));
$good = iconv ("UTF-8", "cp1251" , clear_string($_POST['good']));
$bad = iconv ("UTF-8", "cp1251" , clear_string($_POST['bad']));
$comment = iconv ("UTF-8", "cp1251" , clear_string($_POST['comment']));
mysqli_query ($connection,"INSERT INTO table_reviews(products_id,name,good_reviews,bad_reviews,comment,date)
VALUES(
'".$id."',
'".$name."',
'".$good."',
'".$bad."',
'".$comment."',
NOW()
)");
echo 'yes';
}
Answer the question
In order to leave comments, you need to log in
Field parameters in the form (I hope you have it wrapped in the form?) are passed by name and not by id. It's true that you and the id in the fields do not match what you get in $_POST.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question