i’m trying to make it so that a user can type text in a textarea and then this updates the mysql table ‘bio’ within the database ‘ptb_profiles’.
At the moment their information is being pulled into this textarea but i want it so that whatever they type in it updates the table.
I’m using the following code but it’s not working? im new to php and mysql so it’s bound to be wrong.
Any help would be really appreciated. thanks.
<?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">
The issue is with your text area does not have the name=”bio” property. Also use nl2br and htmlentities and then save in the database. And when getting it back get the real entities back.