【发布时间】:2012-10-24 15:43:15
【问题描述】:
我正在尝试让用户可以在 textarea 中键入文本,然后更新数据库 'ptb_profiles' 中的 mysql 表 'bio'。
目前他们的信息被拉入这个文本区域,但我想要它,以便他们在其中输入的任何内容都会更新表格。
我正在使用以下代码,但它不起作用?我是 php 和 mysql 新手,所以肯定是错误的。
任何帮助将不胜感激。谢谢。
<?php
//We check if the form has been sent
if(isset($_POST['bio']))
{
$content = $_POST['bio'];
//We remove slashes depending on the configuration
if(get_magic_quotes_gpc())
{
$content = stripslashes($content);
}
//We check if all the fields are filled
if($_POST['bio']!='')
{
$sql = "INSERT INTO ptb_profiles.bio VALUES (NULL, '".$_SESSION['user_id']."', '".$message['bio']."');";
mysql_query($sql, $connection);
echo "<div class=\"infobox-message\">Your Profile Information has been updated..</div>";
}
}
?>
<form action="<?php $_SERVER['PHP_SELF'] ?>" method="post">
<textarea id="bio" rows="10" style="width: 456px;
margin-top:3px;
text-align:left;
margin-left:-2px;
height: 122px;
resize: none;
border: hidden;"><?php echo $profile['bio'] ?> </textarea>
<input type="submit" name="send_button" id="send_button" value="Send">
【问题讨论】:
-
“它不工作”是什么意思?不向数据库写入任何内容?网站崩溃?写错信息?将正确的信息写入错误的位置?
-
我点击提交,它只是休眠,什么也没做。 0 null 绝对没有。 ://