0

How can I get text area to post to my array and then be stored in the MySQL Database. Every element of the form works except for the "textarea" part Here is the code I have... Any help is appreciated! Thank You!!

<form action="" method="post">
    <ul>
        <li>
            First name*:<br>
            <input type="text" class="standard" name="first_name" value="<?php echo $user_data['first_name']; ?>">
        </li>
        <li>
            Last name:<br>
            <input class="standard" type="text" name="last_name" value="<?php echo $user_data['last_name']; ?>">
        </li>
        <li>
            Email*:<br>
            <input class="standard" type="text" name="email" value="<?php echo $user_data['email']; ?>">
        </li>
        <li>
            Phone Number:<br>
            <input class="standard" type="text" name="phone" value="<?php echo $user_data['phone']; ?>">
        </li>
        <li>
            About Me:<br>
            <textarea id="textarea" maxlength="1000" name="summary" value="<?php echo $user_data['summary']; ?>"></textarea>
            <div id="textarea_feedback"></div>
        </li>
        <li>
            Account type:<br>
            <select name="type">
                <option value="0" <?php if ($user_data['type'] == 0) echo "selected"; ?>>Employee</option>
                <option value="1" <?php if ($user_data['type'] == 1) echo "selected"; ?>>Employer</option>
            </select>
        </li>
        <li>
            <input type="submit" value="Update">
        </li>
    </ul>
</form>

So the "About Me" textarea is not working.

Here is the php sending it to the database:

<?php
if (isset($_GET['success']) === true && empty($_GET['success']) === true) {
echo 'Your details have been updated!';
} else {
if (empty($_POST) === false && empty($errors) === true) {

    $update_data = array(
        'first_name'    => $_POST['first_name'],
        'last_name'     => $_POST['last_name'],
        'email'         => $_POST['email'],
        'type'          => $_POST['type'],
        'phone'         => $_POST['phone'],
        'summary'       => $_POST['summary']
    );

    update_user($session_user_id, $update_data);
    header('Location: settings.php?success');
    exit();

} else if (empty($errors) === false) {
    echo output_errors($errors);
}
?>

Here is the function sending to database.

function user_data($user_id) {
$data = array();
$user_id = (int)$user_id;

$func_num_args = func_num_args();
$func_get_args = func_get_args();

if ($func_num_args > 1) {
    unset($func_get_args[0]);

    $fields = '`' . implode('`, `', $func_get_args) . '`';
    $data = mysql_fetch_assoc(mysql_query("SELECT * FROM `users` WHERE `user_id` LIKE $user_id"));

    return $data;
}
}
7
  • 1
    textareas don't use the value property, instead the value is the content of the tag. Commented Apr 7, 2015 at 16:03
  • I don't see any SQL to support the question. Commented Apr 7, 2015 at 16:09
  • Plus, an edit was made form action="" method="post"> to <form action="" method="post"> - So, if that's what you were actually using, then that's part of the problem. Commented Apr 7, 2015 at 16:10
  • 'first_name', 'last_name', 'email', 'type', 'phone' all work well. It is just the text area with the name 'summary that isn't Commented Apr 7, 2015 at 16:14
  • This is a select, not an update. Also please do not use the mysql extension, instead resort to the more secure mysqli or pdo extensions Commented Apr 7, 2015 at 16:15

2 Answers 2

1
<textarea id="textarea" maxlength="1000" name="summary" value="<?php echo $user_data['summary']; ?>"></textarea>

Change that line to:

<textarea id="textarea" maxlength="1000" name="summary" ><?php echo $user_data['summary']; ?></textarea>
Sign up to request clarification or add additional context in comments.

Comments

1

There seems to be a typo at the name attribute for your textarea. You wrote name-"summary" instead of name="summary".

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.