douhuan6305 2015-04-07 07: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!!

  1. <form action="" method="post">
  2. <ul>
  3. <li>
  4. First name*:<br>
  5. <input type="text" class="standard" name="first_name" value="<?php echo $user_data['first_name']; ?>">
  6. </li>
  7. <li>
  8. Last name:<br>
  9. <input class="standard" type="text" name="last_name" value="<?php echo $user_data['last_name']; ?>">
  10. </li>
  11. <li>
  12. Email*:<br>
  13. <input class="standard" type="text" name="email" value="<?php echo $user_data['email']; ?>">
  14. </li>
  15. <li>
  16. Phone Number:<br>
  17. <input class="standard" type="text" name="phone" value="<?php echo $user_data['phone']; ?>">
  18. </li>
  19. <li>
  20. About Me:<br>
  21. <textarea id="textarea" maxlength="1000" name="summary" value="<?php echo $user_data['summary']; ?>"></textarea>
  22. <div id="textarea_feedback"></div>
  23. </li>
  24. <li>
  25. Account type:<br>
  26. <select name="type">
  27. <option value="0" <?php if ($user_data['type'] == 0) echo "selected"; ?>>Employee</option>
  28. <option value="1" <?php if ($user_data['type'] == 1) echo "selected"; ?>>Employer</option>
  29. </select>
  30. </li>
  31. <li>
  32. <input type="submit" value="Update">
  33. </li>
  34. </ul>
  35. </form>

So the "About Me" textarea is not working.

Here is the php sending it to the database:

  1. <?php
  2. if (isset($_GET['success']) === true && empty($_GET['success']) === true) {
  3. echo 'Your details have been updated!';
  4. } else {
  5. if (empty($_POST) === false && empty($errors) === true) {
  6. $update_data = array(
  7. 'first_name' => $_POST['first_name'],
  8. 'last_name' => $_POST['last_name'],
  9. 'email' => $_POST['email'],
  10. 'type' => $_POST['type'],
  11. 'phone' => $_POST['phone'],
  12. 'summary' => $_POST['summary']
  13. );
  14. update_user($session_user_id, $update_data);
  15. header('Location: settings.php?success');
  16. exit();
  17. } else if (empty($errors) === false) {
  18. echo output_errors($errors);
  19. }
  20. ?>

Here is the function sending to database.

  1. function user_data($user_id) {
  2. $data = array();
  3. $user_id = (int)$user_id;
  4. $func_num_args = func_num_args();
  5. $func_get_args = func_get_args();
  6. if ($func_num_args > 1) {
  7. unset($func_get_args[0]);
  8. $fields = '`' . implode('`, `', $func_get_args) . '`';
  9. $data = mysql_fetch_assoc(mysql_query("SELECT * FROM `users` WHERE `user_id` LIKE $user_id"));
  10. return $data;
  11. }
  12. }

展开全部

  • 写回答

2条回答 默认 最新

  • douliaotong4944 2015-04-07 08: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条)
编辑
预览

报告相同问题?

手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部