PHP script: Let users create their own accounts

Use this forum if you have problems with a hMailServer script, such as hMailServer WebAdmin or code in an event handler.
denlou

PHP script: Let users create their own accounts

Postby denlou » 2004-11-20 06:38

http://denlou.ca/software/signup.zip

I created this software to interface with the MySQL database and a user to create their own accounts. This may have already been done, but here's my version.

jlcarbwood
New user
New user
Posts: 3
Joined: 2005-03-02 07:26

Postby jlcarbwood » 2005-03-15 00:35

I was searching the forums for something like this. I check that link, but it's invalid. If anyone know where i can get something with an auto registration. I will like maybe the owners of the domain be able to use a web interface, or just a webinterface that user can register their e-mail with a preassing domain name.

Thank you in advanced.

Jorge

User avatar
martin
Developer
Developer
Posts: 6677
Joined: 2003-11-21 01:09
Location: Sweden
Contact:

Postby martin » 2005-03-15 09:45

In hMailServer 4.0, the PHPWebAdmin has support for different administration levels. For example, you can give a user domain administration rights. With this, he can create accounts, etc and change settings for his domain.

johnm
New user
New user
Posts: 16
Joined: 2005-03-23 17:28

Postby johnm » 2005-03-29 08:36

Hi Martin
can you give me a tip on how to do that? All I can find is the ONE admin user / password combo in the config.php ... Does it work through the e-mail-account authentication? What do I need to set up to have more than one admin in PHPWebAdmin?
Thanks!
John

User avatar
martin
Developer
Developer
Posts: 6677
Joined: 2003-11-21 01:09
Location: Sweden
Contact:

Postby martin » 2005-03-29 12:49

Tip on how to do what?

As I said, the feature is avaialble in hMailServer 4.0. Are you using that version?

johnm
New user
New user
Posts: 16
Joined: 2005-03-23 17:28

Postby johnm » 2005-03-29 13:50

Ah, ok, I see, I have 3.4B69 installed - so you're really saying, it will be in v4? :) Would taking the PHPWebAdmin-Interface from v4 Beta B91 to v3.4 work (possibly upgrading the database as well)? (or is the ETE for the non-beta v4 close enough to wait?) - Sorry for all these questions Martin + Thanks for the great work!!

John

denlou
New user
New user
Posts: 6
Joined: 2004-11-22 08:37
Location: Richmond/Vancouver, BC
Contact:

Postby denlou » 2005-04-13 05:45

Alright, I wrote some crude PHP code to interface with the MySQL DB, it's back up for all those who requested it..

http://denlou.ca/software/signup.zip

User avatar
martin
Developer
Developer
Posts: 6677
Joined: 2003-11-21 01:09
Location: Sweden
Contact:

Postby martin » 2005-04-13 08:43

johnm:
Yes, it will be in v4. You can't use v4beta PHPWebAdmin in 3.4. The V4 beta utilizes a lot of new features in V4 that does not exist in 3.4.

I will hopefully put up v4.0 as "unstable" on the download page tomorrow.

chris.hamberg
New user
New user
Posts: 5
Joined: 2005-04-08 13:10
Contact:

Postby chris.hamberg » 2005-04-13 11:24

so when you expecting that the version is stable?
<--ICT--> our way, to the high way.

Esplendidos
New user
New user
Posts: 1
Joined: 2005-05-16 02:28
Contact:

Denlou : Need help with your code !

Postby Esplendidos » 2005-05-16 02:37

Hi all !

This message is for Denlou !

Yo Dude ! i tried your code but can't get it to work !
All the variables are entered correctly (I think !).

A full example of the code would be helpful !

I get these warnings.

Warning: mysql_connect(): Can't connect to MySQL server on 'localhost' (10061) in C:\email\newac\index.php on line 49

Warning: mysql_select_db(): Can't connect to MySQL server on 'localhost' (10061) in C:\email\newac\index.php on line 50

Warning: mysql_select_db(): A link to the server could not be established in C:\email\newac\index.php on line 50
Unable to open database, contact your administrator!


Thanks for your help !

:twisted:

denlou
New user
New user
Posts: 6
Joined: 2004-11-22 08:37
Location: Richmond/Vancouver, BC
Contact:

Postby denlou » 2005-05-16 02:43

Lines 24-28

Code: Select all

//MySQL Information:
$mysql_host = "localhost"; //Host Name
$mysql_user = ""; //Username
$mysql_pass = ""; //Password
$mysql_db = "hmail"; //Database


You need to fill these in, something like this...

Code: Select all

//MySQL Information:
$mysql_host = "localhost"; //Host Name
$mysql_user = "username"; //Username
$mysql_pass = "password"; //Password
$mysql_db = "hmail"; //Database


The program is having trouble connecting to your database so make sure your mysql account information is correct.

kwarner
New user
New user
Posts: 8
Joined: 2005-08-11 23:57

this is a great script

Postby kwarner » 2005-08-17 07:00

I suggest making this topic sticky, since the script is excellent and just looking at the first few pages of topics I noticed about 5 different topics on this subject. That, or putting this script somewhere where it is accessible to people, so it doesn't get relegated to page 20 or so in this forum. Just put it in your web server directory and run after minor configuring. Written in PHP and easily modified for those who know it, though you don't necessarily have to know PHP for it to work correctly.

Some notes about it:

I removed the IMAP, POP, and SMTP variables in the configuration portion of the beginning of the script, as well as in the portion where these are echoed back to the user. I saw no use in relaying this to the user since they probably only care about access to webmail. Also, made a new variable, $domain_name, and replaced every instance of $temp_domain with this. For some reason $temp_domain wasn't working right. I still have some minor configuration to do for it, but it's working great now anyway. Finally, though I'm not sure, I don't think the $account_max variable should be listed as "2000000" but only as "2" for an account with a max size of 2 MB.

The only problem so far really is that the hmailserveradmin program doesn't seem to recognize the accounts created with this script. However, the database and server both do, so you can immediately start using your account after it is created. I don't know what's up with the admin program, but I really don't need to mess with the user accounts anyway.

kwarner
New user
New user
Posts: 8
Joined: 2005-08-11 23:57

encryption

Postby kwarner » 2005-08-17 07:45

Another problem: this script does not encrypt the password before entering it into the database. To encrypt it, just change the mysql insert query from

Code: Select all

$q3=mysql_query("INSERT INTO `hm_accounts` (`accountdomainid`,`accountaddress`,`accountpassword`,`accountactive`,`accountisad`,`accountmaxsize`) VALUES ('{$_POST['domain']}','{$_POST['user']}@$temp_domain,'{$_POST['pass1']}','$admin_default_activate','0','$account_max')")


to

Code: Select all

$q3=mysql_query("INSERT INTO `hm_accounts` (`accountdomainid`,`accountaddress`,`accountpassword`,`accountactive`,`accountisad`,`accountmaxsize`) VALUES ('{$_POST['domain']}','{$_POST['user']}@$temp_domain,SHA('{$_POST['pass1']}'),'$admin_default_activate','0','$account_max')")


...basically, put SHA('password')

And to authenticate, use this function again in a select query comparing the user's attempted and stored passwords.

Now, does anyone know how to do this with SquirrelMail?

denlou
New user
New user
Posts: 6
Joined: 2004-11-22 08:37
Location: Richmond/Vancouver, BC
Contact:

Postby denlou » 2005-08-17 19:32

Well the only reason that I never programmed this in originally is because SquirrelMail doesn't support it, you might want to see if SquirrelMail has a development forum and suggest that feature, though it can't be hard to do, I'll look into it when I get back, but I'm re-writting the code for this entire script if I do change code with SquirrelMail.

User avatar
martin
Developer
Developer
Posts: 6677
Joined: 2003-11-21 01:09
Location: Sweden
Contact:

Postby martin » 2005-08-17 22:54

I wouldn't use SHA('pass'). At least not if I want my users to be able to log on... hMailServer uses a MD5 checksum and not an SHA checksum. So MD5('pass') would be better. :)

kwarner
New user
New user
Posts: 8
Joined: 2005-08-11 23:57

think I got it

Postby kwarner » 2005-08-18 02:49

That helped. I changed the "SHA" to "MD5". Didn't work, but then I added the "accountpwencryption" field to the insert query, with the value of "2". That worked. Here is new insert in case anyone cares.

Code: Select all

$q3=mysql_query("INSERT INTO `hm_accounts` (`accountdomainid`,`accountaddress`,`accountpassword`,`accountactive`,`accountisad`,`accountmaxsize`,`accountpwencryption`) VALUES ('{$_POST['domain']}','{$_POST['user']}@$domain_name',MD5('{$_POST['pass1']}'),'$admin_default_activate','0','$account_max','2')") or die(mysql_error());
            


I don't think there are any other problems with doing it this way, and having users register email accounts using this script, but I'm by no means an expert. Anyone have any thoughts on potential problems?

alibak
New user
New user
Posts: 7
Joined: 2005-03-06 20:21

Postby alibak » 2005-08-23 05:51

Hi, I was wonderin if I could ask you a question regarding the registration script please.

I followed your changes as posted.

I have multiple domains setup in hmail server.

in the registration page, the domains show up as a drop down menu.

I go through the registration and everything is sort of fine. EXCEPT: in the hmail server control panel and in the mysql database, the @domain.com part of the new account created is not written off. So, lets say if I created an account of "hello@domain.com", then, "hello" shows up under the domain.com accounts however NOT as hello@domain.com, but rather simply as "hello@", without the domain.com portion..... THEREFORE an error is created and both the server admin of hmail and the mysql consider it as incomplete and error registration and it doesn't work...

I think in the index.php /registration form, after choosing the domain name in the drop down menu, somehow it doesn't get trasferred to the database....

I'm not a programmer.

Could you please help me fix this?

Also, would you mind tell me how I could add a: "New Registration", "lost your password" to the login page that would go to this form page and comeback to the login page?

if you have a script that is made nice already available, and if you don't mind sharing it, I'd love it!

my email is: dralibak@yahoo.com

Thank you.

Ali

alibak
New user
New user
Posts: 7
Joined: 2005-03-06 20:21

Postby alibak » 2005-08-24 02:05

Hi, nobody has read this post? or no-one has an answer ? ! :)

Thanks.

User avatar
martin
Developer
Developer
Posts: 6677
Joined: 2003-11-21 01:09
Location: Sweden
Contact:

Postby martin » 2005-10-09 13:37

You probably didn't receive an answer because creating such a thing requires you to write at least a 30-40 lines of PHP code. Find a PHP developer that can help you with this. :)

User avatar
Domi
New user
New user
Posts: 10
Joined: 2005-11-08 05:33
Location: Sweden
Contact:

Postby Domi » 2005-11-09 02:17

alibak wrote:Hi, I was wonderin if I could ask you a question regarding the registration script please.

I have multiple domains setup in hmail server.

in the registration page, the domains show up as a drop down menu.
I go through the registration and everything is sort of fine. EXCEPT: in the hmail server control panel and in the mysql database, the @domain.com part of the new account created is not written off. So, lets say if I created an account of "hello@domain.com", then, "hello" shows up under the domain.com accounts however NOT as hello@domain.com, but rather simply as "hello@", without the domain.com portion..... THEREFORE an error is created and both the server admin of hmail and the mysql consider it as incomplete and error registration and it doesn't work...


Hi , check the $q3 query for {$_POST['user']}@$domain_name

change $domain_name to $temp_domain
And your dropp list inserts to the db should work fine unless you altered code along with that ..

Keago
New user
New user
Posts: 6
Joined: 2006-05-23 00:41

Just a quick thought!

Postby Keago » 2006-06-01 00:03

For those who wonder if this code is working the way it should... I found there was a small problem with the bottom part of the script... I couldnt seem to get this working when it seemed simple enough!

Heres what I did

Find somewhere around line 130 on your script, where it says

Code: Select all

<form action=\"index.php?mode=do\" method=\"POST\">


I had to rename where it says "index.php" to what I renamed my script as , say , "signup.php" . I guess where I origionally has an index.php in my root folder when I re-named it in orser to use it locally it didnt work. Simple fix,

The following codes were changed as well:


change $domain_name to $temp_domain

hope this some-what helps you out!

Kingo
New user
New user
Posts: 8
Joined: 2006-09-04 07:02
Location: Brisbane, Australia
Contact:

Re: PHP script: Let users create their own accounts

Postby Kingo » 2006-09-04 07:04

denlou wrote:http://denlou.ca/software/signup.zip


Apologies for the slooow reply, but is this script still available somewhere? The above link returns a 404 :(

Cheers,
Kingo

ChoOSeN
New user
New user
Posts: 1
Joined: 2006-09-23 03:17
Location: Athens, Greece
Contact:

Re: PHP script: Let users create their own accounts

Postby ChoOSeN » 2006-09-23 03:19

denlou wrote:http://denlou.ca/software/signup.zip


This link doesen't work! :roll:

denlou
New user
New user
Posts: 6
Joined: 2004-11-22 08:37
Location: Richmond/Vancouver, BC
Contact:

Postby denlou » 2006-09-24 05:52

wow, I just reinstalled HMail for another project, it's been a while since I wrote that. You know, I think I saw it the other day on one of my hard drives, but god knows where the copy of that software is now.

wilvers
New user
New user
Posts: 2
Joined: 2006-11-04 23:26

Postby wilvers » 2006-11-05 14:37

Does ahyone have the code they could send me at all? The link doesn't work anymore

User avatar
[PT]Cableguy
New user
New user
Posts: 25
Joined: 2007-02-22 11:09
Location: Portugal

Postby [PT]Cableguy » 2007-02-22 11:30

Please take a look at the following post:

http://www.hmailserver.com/forum/viewto ... 4027#44027
aka: Bruno Vaz

hMailServer-4.3.1-B253 + phpwebadmin + roundcubemail-0.1beta2.2 + clamwin-0.88.7

PsyDonia
New user
New user
Posts: 18
Joined: 2006-10-03 16:28

Postby PsyDonia » 2007-08-29 12:46

can someone plz make the signup code downloadable.

^DooM^
Site Admin
Posts: 13853
Joined: 2005-07-29 16:18
Location: UK

Postby ^DooM^ » 2007-08-29 12:56

Follow Cableguys's link.

Batista
New user
New user
Posts: 1
Joined: 2009-08-23 12:09

Re: PHP script: Let users create their own accounts

Postby Batista » 2009-08-23 12:15

Yes I will follow that. Seems very reliable. It is worth a try.

Thanks a lot.


Pret immobilier

ohshhitscarl
New user
New user
Posts: 1
Joined: 2010-08-05 15:57

Re: PHP script: Let users create their own accounts

Postby ohshhitscarl » 2010-08-05 15:58

Sorry to revive an old topic. When I add users using a SQL query in hMail v5.3.3, the user gets added to the domain in the database but when mail is sent to this user, I can see the message arriving to a generic mailbox; NOT to the user it was meant for.
Any insight?

Bill48105
Developer
Developer
Posts: 6171
Joined: 2010-04-24 23:16
Location: Michigan, USA

Re: PHP script: Let users create their own accounts

Postby Bill48105 » 2010-08-09 14:03

Yeah best to start your own thread & link to ones you feel might be related.

I'd say add a user with hmail's admin GUI/web & test it to make sure it goes to the user's box & your setup is how you think then add a user the way you're trying now & compare the SQL rows to see if you missed something like enabling the user or typo or putting in wrong db/table, etc.. If that doesn't work try restarting hmail service after adding to see if it's a caching issue.
Bill
*** ABSENT FROM hMail! Those in IRC know how to find me if urgent. ***
hMailServer build LIVE on my servers: 5.4-B2014050402
Latest test builds: http://www.hmailserver.com/forum/viewtopic.php?f=10&t=21420

thedealer
New user
New user
Posts: 7
Joined: 2011-07-14 18:39

Re: PHP script: Let users create their own accounts

Postby thedealer » 2011-07-15 17:45

Bill48105 wrote:Yeah best to start your own thread & link to ones you feel might be related.

I'd say add a user with hmail's admin GUI/web & test it to make sure it goes to the user's box & your setup is how you think then add a user the way you're trying now & compare the SQL rows to see if you missed something like enabling the user or typo or putting in wrong db/table, etc.. If that doesn't work try restarting hmail service after adding to see if it's a caching issue.
Bill


Bill,

Having a similar issue and I feel it is appropriate to post on this thread because I have the same thing happening and can't quite understand some of the lingo you are using (I am on the forum at the request of my boss to help trouble shoot some IT issues). Very similar issue happening here with the generic mailbox. They are going to the right domain, but for some reason they are going to a general inquiry box instead of the individual employee to which the mail was supposedly targeted. I hope I am being understandable...It's like there is a filter pushing the mail aside...

^DooM^
Site Admin
Posts: 13853
Joined: 2005-07-29 16:18
Location: UK

Re: PHP script: Let users create their own accounts

Postby ^DooM^ » 2011-07-15 20:25

thedealer. Start a new thread with your issues or your post will be deleted.

Also read this viewtopic.php?f=6&t=12211
If at first you don't succeed, bomb disposal probably isn't for you! ヅ


Return to “Scripting”



Who is online

Users browsing this forum: No registered users and 0 guests