title: How to send $_POST data from form to function with other variables?
body: <p>I'm trying to pass data from a form to another function in another file, but this function already has other variables that is coming from another function.</p>
  
  <pre><code>&lt;form method="post" action="data.php"&gt;
      &lt;input type="hidden" name="url" value="http://www.website.com/"&gt;
      &lt;input type="hidden" name="description" value="description of website"&gt;
      &lt;input type="hidden" name="image" value="http://www.website.com/image.jpg"&gt;
      &lt;input type="hidden" name="board_ids" value="$board_ids"&gt;
  &lt;/form&gt;
  </code></pre>
  
  <h2>data.php</h2>
  
  <pre><code>&lt;?php
      function login()
      {
          random variables with cURL included which is passing data to the post function
  
          post($ch, $cookie, $url);
      }
  
      function post()
      {
          uses $ch, $cookie, $url.
      }
  ?&gt;
  </code></pre>
  
  <p>Now, above function login(), I have the following..</p>
  
  <pre><code>$post_url       = $_POST['url'];
  $post_desc  = $_POST['description'];
  $post_image    = $_POST['image'];
  $board_ids      = $_POST['board_ids'];
  </code></pre>
  
  <p>PS: board_ids is an array with a few specific id's, ex: <code>$board = array('102938', '483756', '002938', '239384');</code></p>
  
  <pre><code>for($i = 0; $i &lt; count($board_ids); $i++ )
  {
      post($board_ids[$i]);
  }
  </code></pre>
  
  <p>I want to know how I can send the $post_url, $post_desc, $post_image and $board_ids to the post() function.</p>
  
  <p>I was actually wanting to make post() run each time with each board_id array, is that possible? the above keeps saying I have <code>PHP Notice:  Undefined offset: 2</code> on the post function. Been at it for 9 hours straight and can't pass the variables to the post function, had to ask for help.</p>
  
  <p>EDIT</p>
  
  <pre><code>&lt;?php
  foreach($pinterestClass-&gt;retrieveAllInfo() as $data)
  {
      echo '
      &lt;tr&gt;
  
          &lt;form method="post" action"data.php"&gt;
  
              &lt;td rowspan="1" colspan="1"&gt;
                  &lt;input type="hidden" name="post_url" value="'.$data['p_Url'].'"&gt;'.$data['p_Url'].'
              &lt;/td&gt;
  
              &lt;td rowspan="1" colspan="1"&gt;
                  &lt;input type="hidden" name="post_description" value="'.$data['p_Description'].'"&gt;'.$data['p_Description'].'
              &lt;/td&gt;
  
              &lt;td rowspan="1" colspan="1"&gt;
                  &lt;input type="hidden" name="post_image" value="'.$data['p_Image'].'"&gt;'.$data['p_Image'].'
              &lt;/td&gt;
  
              &lt;td rowspan="1" colspan="1"&gt;
                  &lt;section id="list1" class="dropdown-check-list" onclick="firstDropDown(this)"&gt;
                      &lt;span class="anchor"&gt;Boards&lt;/span&gt;
                      &lt;ul class="items"&gt;';?&gt;
                      &lt;?php 
                          $p_iD = $data['p_iD'];
                          $checkedBoards = $oClass-&gt;pCheckedBoards($p_iD);
  
                          foreach($pClass-&gt;retrieveBoards() as $data)
                          {
                              $boardiD    =   $data['boardiD'];
                              $boardName  =   $data['boardName'];
  
                              $checked = '';
  
                              for($i = 0; !$checked &amp;&amp; $i &lt; sizeof($checkedBoards); $i++)
                              {
                                  if($checkedBoards[$i]['board_iD'] == $boardiD)
                                  {
                                      $checked = 'checked="checked"';
                                  }
                              }
  
                              echo '
                                  &lt;li&gt;&lt;input '.$checked.' type="checkbox" name="post_board_id" value="'.$boardiD.'"&gt;'.$boardName.'&lt;/li&gt;
                              ';
                          }
                      ?&gt;
                      &lt;?php echo '
                      &lt;/ul&gt;
                  &lt;/section&gt;
              &lt;/td&gt;
  
              &lt;td rowspan="1" colspan="1"&gt;
                  Status
              &lt;/td&gt;
  
              &lt;td rowspan="1" colspan="1"&gt;
                  &lt;div style="background: none repeat scroll 0px 0px rgb(229, 229, 229); padding-top: 5px; height: 22px;"&gt;
                      &lt;i class="fa fa-edit"&gt;&lt;/i&gt; &lt;input name="post_info" type="submit" class="btn btn-xs default" value="Edit"&gt;
                  &lt;/div&gt;
              &lt;/td&gt;
  
          &lt;/form&gt;
  
      &lt;/tr&gt;
      ';
  }
  ?&gt;
  </code></pre>
  
  <h2>data.php</h2>
  
  <pre><code>&lt;?php
  
      error_reporting(E_ALL);
      ini_set('display_errors', 1);
  
      $post_desc  = $_POST['post_description'];
      $post_url   = $_POST['post_url']';
      $post_image = $_POST['post_image'];
  
      $board = $_POST['post_board_id'];
      for($i = 0; $i &lt; count($board); $i++ )
      {
          $board[$i];
      }
  
      function pinLogin()
      {
          $username   = '';
          $password   = '';
  
          $Cookie = '/cookie.txt'; //cookie session
  
          // this is the http post data for logging in - username &amp; password are substituted in later
          $login_post     = array(
              'source_url' =&gt; '/login/',
              'data' =&gt; '{
                  "options":{
                      "username_or_email":"%s",
                      "password":"%s"
                      },
                  "context":{}}',
          );
  
          // cURL so it needs $ch, $url is the login url
  
          pinPost($ch, $Cookie, $url);
      }
  
      function Post($ch, $pinCookie, $url)
      {
          $boardId    = $board[$i];
          $postDesc   = $post_desc;
          $postUrl    = $post_url;
          $postImage  = $post_image;
  
      }
  
  
      Login();    
  
  ?&gt;
  </code></pre>