我有一个textarea
表单,我将其发送给PHP POST
。
php接收POST并插入mysql:
$descricao = $_POST['descricao'];
$stmt = $mysqli->prepare("INSERT INTO posts (descricao) VALUES (?)");
$stmt->bind_param('s', $descricao);
$stmt->execute();
插入正常。问题是如果我尝试在我的textarea中添加PHP代码,例如:
text...
<?php
echo"";
?>
text...
descricao
只有这个:
text...
text...
如何在mysql中添加php代码?为什么它不起作用?
答案 0 :(得分:0)
使用PDO尝试此操作:
$descricao = $_POST['descricao'];
$query = "INSERT INTO post(descricao) VALUES(:des_value)";
$stmt = $this->conn->prepare($query);
$stmt->execute(array(
':des_value' => $descricao,
));