title: php validation using cURL
body: <p>im trying to validate a form using php because it has a file input in it that requires validation.</p>
  
  <p>basically, the action of my form sends it to validate.php, which validates the form fields and either sends the invalid data back to the form using POST in cURL:</p>
  
  <pre><code>$data = array(
      'nameError' =&gt; $nameError,
      'name' =&gt; $name,
      'description' =&gt; $desc,
      'descError' =&gt; $descError,
      'spriceError' =&gt; $spriceError,
      'sprice' =&gt; $sprice,
      'iprice' =&gt; $iprice,
      'incprice' =&gt; $incprice,
      'incprice' =&gt; $incprice,
      'durError' =&gt; $durError,
      'location' =&gt; $location,
      'img' =&gt; $imgError
  );
  
  foreach($data as $key=&gt;$value){
      $field_string .= $key.'='.$value.'&amp;';
  
  }
  rtrim($field_string, '&amp;');
  
  
  $ch = curl_init();
  
  curl_setopt($ch, CURLOPT_URL, 'sellanitem.php');
  curl_setopt($ch, CURLOPT_POST, count($data));
  curl_setopt($ch, CURLOPT_POSTFIELDS, $field_string);
  
  curl_exec($ch);
  
  curl_close($ch);
  header("Location: sellanitem.php");
  </code></pre>
  
  <p>in my form page, i check to see if the post data is set:</p>
  
  <pre><code>if(isset($_POST['name'])){
      $name = $_POST['name'];
  
  }else{
      $name = "";
  }
  
  if(isset($_POST['nameError'])){
      $nameError = $_POST['nameError'];
  }else{
      $nameError = "";
  }
  
  if(isset($_POST['durError'])){
      $durError = $_POST['durError'];
  
  }else{
      $durError = "";
  }
  
  if(isset($_POST['description'])){
      $desc = $_POST['description'];
  
  }else{
      $desc = "";
  }
  </code></pre>
  
  <p>etc.</p>
  
  <p>then i display messages based on the values of the variable:</p>
  
  <pre><code>            &lt;td&gt;
                  &lt;textarea id="name" name="name" title="name" rows="2" cols ="60" style="resize:none; float:right; font-family: Arial;" value=""&gt;&lt;?php echo $name;?&gt;&lt;/textarea&gt;
  &lt;?php
  if($nameError != ""){
      echo $nameError;
  }
  </code></pre>
  
  <p>i came to this method after looking up "submit form automatically php" in google. my thought was that if i could automatically submit a form i could simply include the error messages as data fields with an action back to my sellanitem.php. i dont know thought, this cURL stuff is confusing to me, so far i submit the form fields with invalid inputs to test it and it simply loads a blank page. i also tried putting header("location: sellanitem.php") but the error messages arent displayed. </p>
  
  <p>suggestions of what might be wrong / alternate methods that would achieve the same result?</p>
  
  <p>cheers, 
  bundy</p>