1 (edited by SoberStoner 2018-11-06 14:02:08)

Topic: PHP / HTML Register Form

==== REQUIRED BASIC INFO OF YOUR IREDMAIL SERVER ====
- iRedMail version 0.9.8:
- Linux/BSD distribution Ubuntu 18.04 x64:
- Store mail accounts in MySQL:
- Web server Nginx:
- Manage mail accounts with iRedAdmin-Pro? No
- [IMPORTANT] Related original log or error message is required if you're experiencing an issue.
====

Hello, I have created a very simple form to allow other members of my team to create their own email accounts but it does not seem to be working and I'm not sure what the mistake could be.
Also, not too sure if support for this kind of issue is provided here.
After I click submit on the form, the webpage just loads forever and no email account is created. Any help would be greatly appreciated.

This is the form:

<html>   
   <body>
      <?php
         if(isset($_POST['add'])) {
            $dbhost = 'IP';
            $dbuser = 'root';
            $dbpass = 'password';
            $dbname = 'vmail';
            $conn = mysql_connect($dbhost, $dbuser, $dbpass, $dbname); 
            if(! $conn ) { die('Could not connect: ' . mysql_error()); }
            if(! get_magic_quotes_gpc() ) {
$STORAGE_BASE = "$(dirname $[STORAGE_BASE_DIRECTORY])";
$STORAGE_NODE = "$(basename $[STORAGE_BASE_DIRECTORY])";
               $username = addslashes ($_POST['username']);
               $domain = addslashes ($_POST['domain']);
            $password = $_POST['password']; }
            $sql = "INSERT INTO mailbox ". "(username,password,name,storagebasedirectory,storagenode,quota,domain,active,passwordlastchange,created) ". "VALUES('$username@$domain', '$password', '$username', '$STORAGE_BASE','$STORAGE_NODE', '100', '$domain', '1', NOW(), NOW())";
mysql_close($conn);  }else {  ?>
               <form method = "post" action = "<?php $_PHP_SELF ?>">
                  <table width = "400" border = "0" cellspacing = "1" cellpadding = "2">
                     <tr>
                        <td width = "100">User Name</td>
                        <td><input name = "username" type = "text" id = "username"></td>
                     </tr>
                     <tr>
                        <td width = "100">Domain</td>
                        <td><input name = "domain" type = "text" id = "domain"></td>
                     </tr>
                     <tr>
                        <td width = "100">Password</td>
                        <td><input name = "password" type = "text" id = "password"></td>
                     </tr>
                     <tr>
                        <td width = "100"> </td>
                        <td> </td>
                     </tr>
                     <tr>
                        <td width = "100"> </td>
                        <td>
                           <input name = "add" type = "submit" id = "add" value = "Add Email">
                        </td>
                     </tr>
                  </table>
               </form>
            <?php}?>
</body>
</html>

----

Spider Email Archiver: On-Premises, lightweight email archiving software developed by iRedMail team. Supports Amazon S3 compatible storage and custom branding.

2

Re: PHP / HTML Register Form

SoberStoner wrote:

After I click submit on the form, the webpage just loads forever and no email account is created. Any help would be greatly appreciated.

You need to check your php code, or web server log files.

3

Re: PHP / HTML Register Form

ZhangHuangbin wrote:
SoberStoner wrote:

After I click submit on the form, the webpage just loads forever and no email account is created. Any help would be greatly appreciated.

You need to check your php code, or web server log files.


Hey, Thanks for the reply.

The only error that I am receiving is "Trying to get property of non-object" which I don't believe is even related to this issue.
In addition, I have also changed all the 'mysql' to 'mysqli' since mysql functions are deprecated in php7.0

4 (edited by SoberStoner 2018-11-08 04:30:05)

Re: PHP / HTML Register Form

Alright, I believe I figured out the exact issue but can not figure out how to fix it.

First of all, I did realize that I made the most newbish mistake xD by using the root user to connect.
So I got a new error message of "PHP Warning:  mysqli_connect(): (HY000/2002): Connection timed out"
Which made me realize, that I was using the wrong user and didn't have remote connections open.
I have create a new mysql user with all privileges to 'localhost' and '%'
As well as changed the 'bind-address' to '0.0.0.0'
but I am still receiving the time out error.

**UPDATE**
I have worked out the connection issue but now it's saying "Unknown database 'vmail' "
Though I see the database.... After running 'show databases' in ssh, 'vmail' is listed.
What could I possibly be missing?
Also, the tables that I listed before, are those the proper ones to be using to insert the email?