Advertisement
bowenac

Insert Each Line Textarea

Aug 31st, 2013
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.46 KB | None | 0 0
  1. <?php
  2. /*
  3. Template Name: ad task
  4. */
  5.  
  6. global $wpdb;
  7. ?>
  8. <?php
  9. if (isset($_POST['submit']))
  10. {
  11. $table_name = $wpdb->prefix . "tasks";
  12. $user_ID = get_current_user_id();
  13. $values = $_POST['taskName'];
  14. $array = split("\r\n", $values);
  15. foreach($array as $line){
  16. $wpdb->insert( $table_name, array( 'task_name' => $line, 'user_id' => $user_ID ) );
  17. echo'<script> window.location="/demos/Anthony/my-tasks/"; </script> ';
  18. }
  19. }
  20. else
  21. {
  22.    echo "no data posted";
  23. }
  24. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement