通过表单发送特殊字符并插入mysqli

时间:2016-04-18 23:32:50

标签: php forms mysqli special-characters

我已经搜索过了,但找不到任何有效的东西,即使是不起作用也是如此:

index.php

<head>
<meta charset="utf-8">
</head>

<form action="upload.php" method="post" enctype="multipart/form-data" accept-charset="UTF-8">
titel: <input style="width: 300px; margin-left: 104px;" type="text" name="titel">
<input type="submit" value="UPLOAD">
</form>

upload.php

<head>
<meta charset="utf-8">
</head>


<?php
if(isset($_POST['titel']))
{
    $con = mysqli_connect("localhost","trhdrth","fhrth","trhdrth");

    $titel = mysqli_real_escape_string($con, $_POST['titel']);

    mysqli_query($con, "INSERT INTO artikel (titel)
    VALUES ('" . $titel . "')");
}
?>

titelblablabla时,我工作的所有内容都是смешные,然后才能正常工作

如何正确做到?

0 个答案:

没有答案