douhuan6305 2015-04-07 15:59
浏览 65
已采纳

从textarea发送数据到mysql

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;
}
}
  • 写回答

2条回答 默认 最新

  • douliaotong4944 2015-04-07 16:12
    关注
    <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>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 使用C#,asp.net读取Excel文件并保存到Oracle数据库
  • ¥15 C# datagridview 单元格显示进度及值
  • ¥15 thinkphp6配合social login单点登录问题
  • ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配