title: How to put POST form data in action
body: <p>I am trying to setup a user creation API for VestaCP. I have these two pages.</p>
  
  <p>The form:</p>
  
  <pre><code>&lt;form action="process.php" method="post"&gt;
  Username:&lt;br&gt;
  &lt;input type="text" name="username"&gt;
  &lt;br&gt;
  Password:&lt;br&gt;
  &lt;input type="password" name="password"&gt;
  &lt;br&gt;
  Email Address:&lt;br&gt;
  &lt;&lt;input type="email" name="email"&gt;
  &lt;br&gt;&lt;br&gt;
  &lt;input type="submit" value="Submit"&gt;
  &lt;/form&gt; 
  </code></pre>
  
  <p>Then the action:</p>
  
  <pre><code>&lt;?php
  // Server credentials
  $vst_hostname = 'MYSERVERADDRESS';
  $vst_username = 'MYSERVERUSERNAME';
  $vst_password = 'MYSERVERPASSWORD';
  $vst_command = 'v-add-user';
  
  // New Account
  $username = 'username';
  $password = 'password';
  $email = 'email'; 
  $package = 'Free';
  $fist_name = 'Null';
  $last_name = 'Null';
  
  // Prepare POST query
  $postvars = array(
  'user' =&gt; $vst_username,
  'password' =&gt; $vst_password,
  'returncode' =&gt; $vst_returncode,
  'cmd' =&gt; $vst_command,
  'arg1' =&gt; $username,
  'arg2' =&gt; $password,
  'arg3' =&gt; $email,
  'arg4' =&gt; $package,
  'arg5' =&gt; $fist_name,
  'arg6' =&gt; $last_name
  );
  $postdata = http_build_query($postvars);
  
  // Send POST query via cURL
  $postdata = http_build_query($postvars);
  $curl = curl_init();
  curl_setopt($curl, CURLOPT_URL, 'http://' . $vst_hostname . ':8083/api/');
  curl_setopt($curl, CURLOPT_RETURNTRANSFER,true);
  curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
  curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
  curl_setopt($curl, CURLOPT_POST, true);
  curl_setopt($curl, CURLOPT_POSTFIELDS, $postdata);
  $answer = curl_exec($curl);
  
  // Check result
  if($answer == 0) {
  echo "User account has been successfuly created\n";
  } else {
  echo "Query returned error code: " .$answer. "\n";
  }
  ?&gt;
  </code></pre>
  
  <p>I think the problem is inputting the form data into the php script but I'm not very experienced so I don't know.</p>
  
  <p>The API is connecting to my server correctly as I tested the same </p>
  
  <pre><code>//Server Credentials
  </code></pre>
  
  <p>part with a different API and it worked.</p>
  
  <p>When I run this script, it outputs "User account has been successfully created" but when I check my control panel, there is no new user.</p>
  
  <p>Thank you for any help.</p>
  
  <p>EDIT: I only wrote the form, this script was made by VestaCP as shown here: <a href="https://vestacp.com/docs/api/" rel="nofollow">https://vestacp.com/docs/api/</a>. The errors in this script are direct from Vesta.</p>