Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7989449
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T12:45:21+00:00 2026-06-04T12:45:21+00:00

I’m trying to create a new ftp account when a PHP form is processed.

  • 0

I’m trying to create a new ftp account when a PHP form is processed. If I enter this address in my browser’s address bar:

http://cpanel_username:cpanel_password@$mydomain.com:2082/json-api/cpanel?cpanel_jsonapi_version=2&cpanel_jsonapi_module=Ftp&cpanel_jsonapi_func=addftp&user=ftp_username&pass=ftp_password&homedir=/the/users/homefolder&quota=0

… json formatted results are shown on the screen and an ftp account is created as specified. However, when I use it in a PHP file, I can’t get it to work! Here’s what I have:

$user = "cpanel_username";
$pass = "cpanel_password";
$domain = "mydomain.com";
$fuser = "ftp_username";
$fpass = "ftp_password";
$fhomedir = "/the/users/homefolder";

$url = "http://$user:$pass@$domain:2082/json-api/cpanel?cpanel_jsonapi_version=2&cpanel_jsonapi_module=Ftp&cpanel_jsonapi_func=addftp&user=$fuser&pass=$fpass&homedir=$fhomedir&quota=0";

file_get_contents($url);

I also tried using CURL:

function new_get_file_contents($url) {
$ch = curl_init();
$timeout = 10; 
curl_setopt ($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$file_contents = curl_exec($ch); 
curl_close($ch);
return $file_contents;
}

new_get_file_contents($url);

Any ideas why I can’t get this to work?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T12:45:23+00:00Added an answer on June 4, 2026 at 12:45 pm

    It’s likely not working because cURL doesn’t have access to a cPanel session / cookies. Entering the URL works directly in a web browser, because the browser is preserving the cPanel session state between requests. The only way to solve this problem is to first login to cPanel using cURL and HTTP POST requests.

    Tools like FireBug and Fiddler can help you see the HTML form elements or exact HTTP POST fields, including HTTP headers, sent when logging in. Emulating the login form process with cURL and then including your code should do the trick.

    This may help you move along:

    • http://www.fiddler2.com/fiddler2/
    • http://getfirebug.com/
    • https login page with curl
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I'm trying to create an if statement in PHP that prevents a single post
Basically, what I'm trying to create is a page of div tags, each has
this is what i have right now Drawing an RSS feed into the php,
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I am trying to understand how to use SyndicationItem to display feed which is
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I would like to count the length of a string with PHP. The string

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.