Page 1 of 1
Problems with adding user
Posted: Sun Aug 16, 2015 3:24 am
by cdg
I don't know if I'm just doing this wrong or what the problem is. I'm trying to make a signup page for Vesta on my site using the API example here:
https://vestacp.com/docs/api/ but it is not working. I asked this on a different forum (
http://stackoverflow.com/questions/3202 ... -in-action) and still have no answer. It tells me that the user account is successfully created and i know that it is connecting to my server correctly but the accounts are not being created. It has been made apparent to me that variables such as
should be
Code: Select all
$username = $_POST['username'];name = $_POST['username'];
and that the script says fist_name rather than first_name. If there is a different version of this or a way to fix this it would be much appreciated. Thanks.
Re: Problems with adding user
Posted: Mon Aug 17, 2015 12:28 pm
by tjebbeke
Try this:
Code: Select all
<form action="process.php" method="post">
Username:<br>
<input type="text" name="username">
<br>
Firstname:<br>
<input type="text" name="firstname">
<br>
Name:<br>
<input type="text" name="name">
<br>
Password:<br>
<input type="password" name="password">
<br>
Email Address:<br>
<input type="email" name="email">
<br><br>
<input type="submit" value="Submit">
</form>
process.php
Code: Select all
<?php
// Server credentials
$vst_hostname = 'MYSERVERADDRESS';
$vst_username = 'admin';
$vst_password = 'ADMINPASSWORD';
$vst_returncode = 'yes';
$vst_command = 'v-add-user';
// New Account
$username = $_POST['username'];
$password = $_POST['password'];
$email = $_POST['email'];
$package = 'default'; // $package = 'Free'; //Free package exist on server?
$fist_name = $_POST['firstname'];
$last_name = $_POST['name'];
// Prepare POST query
$postvars = array(
'user' => $vst_username,
'password' => $vst_password,
'returncode' => $vst_returncode,
'cmd' => $vst_command,
'arg1' => $username,
'arg2' => $password,
'arg3' => $email,
'arg4' => $package,
'arg5' => $fist_name,
'arg6' => $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";
}
?>
Re: Problems with adding user
Posted: Mon Oct 05, 2015 10:31 pm
by cdg
I finally got the form working, the problem was in the post query sectio, where it was trying to post fist_name rather than first_name. Thank you so much!
Re: Problems with adding user
Posted: Wed Mar 09, 2016 9:49 am
by www.rinku31
Yes
turn on errors while developing script:
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
Re: Problems with adding user
Posted: Fri Sep 23, 2016 12:36 pm
by skurudo