0

有人可以帮忙吗,我有一个文本区域表单,用户可以输入内容并提交,然后内容存储在 mysql 表中。

我遇到的问题是,每当用户键入撇号时,它都会插入 / 并且我想摆脱 /。

我的专栏是 utf8_general_ci 格式(长文本)我什至在这里使用了正确的格式类型吗?

这也是我的代码也许我需要在mysql中放一些东西?

请有人告诉我我哪里出错了谢谢。

html表单:

<form action="includes/changebio.php" method="post" id="form1">         
 <textarea id="bio" style="width: 448px; 
    margin-top:3px;
    text-align:left;
    margin-left:-2px;
    height: 120px;
    resize: none; 
    border: hidden;" textarea name="bio" data-id="bio" maxlength="710"><?php echo htmlspecialchars($profile['bio']); ?></textarea>
<input type="image" src="assets/img/icons/save-edit.png"class="bio-submit" name="submit" value="submit" id="submit"/>
</form>

mysql:

<?php ob_start(); ?>
<?php
require_once("session.php"); 
require_once("functions.php");
require('_config/connection.php');
?>
<?php 
session_start();
include '_config/connection.php'; 
$bio = $_POST['bio'];
$result = mysql_query("SELECT bio FROM ptb_profiles WHERE id=".$_SESSION['user_id']."");
if(!$result) 
{ 
echo "The username you entered does not exist"; 
} 
else 
if($bio!= mysql_result($result, 0)) 
{ 
echo ""; 
    $sql=mysql_query("UPDATE ptb_profiles SET bio ='".mysql_real_escape_string($bio)."' WHERE id=".$_SESSION['user_id'].""); 
}
header("Location: {$_SERVER['HTTP_REFERER']}");
?>
<?php ob_end_flush() ?>
4

1 回答 1

1

有2种可能的情况

  1. 你有魔术引号。关闭它们。
  2. 某种Sanitize Them All功能在您的所有输入数据上运行。摆脱它。
于 2013-02-16T18:02:26.273 回答