Add User to Nextcloud via HTML Form + PHP Script

Hi :slight_smile:

My Problem:

I have to code a HTML From + a PHP script which creates a new NC user.

Currently it saves the data from the HTML form in the oc_users table (postgressql)

But I can’t see anything in the Nextcloud GUI.

So how can I transfer the added data from the database in the Nextcloud User GUI?

My Code:

// Database Login Data

$username = "***SENSITIVE DATA***";

$dbpw = "***SENSITIVE DATA***";

$database = "***SENSITIVE DATA***";

$server = "***SENSITIVE DATA***";

$uid = $_POST["uid"];

$displayName = $_POST["displayname"];

$password = $_POST["password"];

$userId = $_POST["uid_lower"];

>  // Ecrypt Password

$password2 = (password_hash('$password', PASSWORD_ARGON2ID, ['memory_cost' => 1<<16 ,'time_cost' => 4, 'threads' => 1]));

    echo $password2;

    // Insert Data in oc_users Table

    $db_connection = pg_connect("host=***SENSITIVE DATA*** dbname=***SENSITIVE DATA*** user=***SENSITIVE DATA*** password=***SENSITIVE DATA***");

    $result = pg_query($db_connection, "INSERT INTO oc_users (uid, displayname, password, uid_lower)








<form action="createUser.php" method="POST">

      <li><input type="text" name="uid"></li>


          <li><input type="text" name="displayname"></li>


          <li><input type="password" name="password"></li>


          <li><input type="text" name="uid_lower"></li>

          <li><input type="submit" /></li>


Hope somebody can help me and Excuse my bad english… :sweat_smile:

kind regards


1 Like

Out of curiosity. Can we use a different script other than UTF-8 for entry fields in a html/PHP form?