no1uno Posted August 22, 2006 Share Posted August 22, 2006 Hello allI am new here (and new to PHP, but trying to learn) and would like to ask if anyone can please help me with a script.I will need to go off the track for a second to explain what I need.I have an email server running on my server to give my members email addresses (hmailserver) and currently I need to set them up manually.I wanted a script so that users can create thier own account, and I found one on the hmailserver forum.Now back to the help I need. The script (below) works fine except that I have 3 domains setup in the MySQL database and the script pulls up all 3 for ther to to choose from when I only want 1 domain available. Can someone see if the script be amended to show only one domain?Thanks in advance.[code]<?php// HMailServer New user signup Script Configurationdie("You have to configure the script first"); // <- remove this line$dbhost = "localhost"; // host of the MySQL database$dbuser = "root"; // Database username$dbpassword = ""; // Your database password$dbname = "hmail"; // the name of the database that has the hmailserver tables$webmailurl = "http://www.yurdomainname.com/webmail/login.php"; // The url to login in the webbased mail system$quota = "50"; // The mailbox free space// Get the actionif (strlen($_POST["pas1"]) <= 4 && IsSet($_POST["pas1"])) {$error .= "<centeR>Error: Your password must be longer than 4 characters</center>";} else if ($_POST["pas1"] == "12345" && IsSet($_POST["pas1"])) {$error .= "<centeR>Error: Too simple password</center>";} if (IsSet($_POST["action"])) {$action = $_POST["action"]; } else {$action = $_GET["action"];}// If there is no action, open the page for a new registrationif (!IsSet($action)) {// Load the domain names and their ids into a variable$db = mysql_connect($dbhost, $dbuser, $dbpassword);mysql_select_db($dbname);$result = mysql_query("SELECT * FROM hm_domains WHERE domainactive = '1' ", $db);$domains = "<select name=\"domain\">";while ($row = mysql_fetch_array($result)) {$domainid = $row['domainid'];$domainname = $row['domainname'];$domains .= "\n<option value=\"$domainid\">$domainname</option>";}$domains .= "\n</select>";mysql_close();echo "<center><b>Open a new E-Mail Account</b><p>(*) fields are reguired.<br><form action=\"\" name=\"registration\" method=\"post\"><table border=\"0\"><tr><td>* Username: <td><input type=\"text\" name=\"username\">@<td>$domains<tr><td>* Password: <td><input type=\"password\" name=\"pas1\"><Td><tr><td>* Password again: <td><input type=\"password\" name=\"pas2\"><Td><tr><td><td><input type=\"hidden\" name=\"action\" value=\"register\"><input type=\"Submit\" value=\"Signup\"><td><tr></td></tr></table>";}else if ($action == "register") {$domainid = $_POST["domain"];$username = $_POST["username"];$pas1 = $_POST["pas1"];$pas2 = $_POST["pas2"];//$firstname = $_POST["firstname"];//$lastname = $_POST["lastname"];if ($username == NULL) { $error = "Error: You have to enter your desired username\n";}if ($domainid == NULL) { $error .= "Error: You have to choose a domain\n<Br>";}if ($pas1 == NULL) { $error .= "Error: You have to enter your password\n<Br>";}if ($pas1 != $pas2) { $error .= "Error: Your passwords does not match\n<Br>";}//if ($firstname == NULL) { //$error .= "Error: You have to enter your first name\n<Br>";//}//if ($lastname == NULL) { //$error .= "Error: You have to enter your last name\n<Br>";//}//Check if the user exists for that domain$db = mysql_connect($dbhost, $dbuser, $dbpassword);mysql_select_db($dbname);$result = mysql_query("SELECT * FROM hm_domains WHERE domainid = '$domainid' ", $db);$result = @mysql_fetch_array($result);$address = $username . "@" . $result['domainname'];$result = mysql_query("SELECT * FROM hm_accounts WHERE accountaddress = '$address' ", $db);$result = @mysql_fetch_array($result);if ($result['accountid'] != "") {$error .= "Error: The E-Mail address $address is already registered, please coose another username or domain\n<Br>";mysql_close();}if (IsSet($error)) {echo "<Center>Oops, There was some errors, please submit the form again<br>";echo $error;}else {// Insert the new user infos$passwd = md5($pas1);$db = mysql_connect($dbhost, $dbuser, $dbpassword);mysql_select_db($dbname);$query = "INSERT INTO hm_accounts (accountaddress, accountdomainid, accountadminlevel, accountpassword, accountactive, accountisad, accountmaxsize, accountpwencryption, accountvacationmessageon) VALUES ('$address','$domainid','0','$passwd','1','0','$quota','2','0')";mysql_query($query) or die("Error: Can not query to the database");mysql_close();echo "<center><B>Completed!</b> <br><br>You have created an email account with us! you can use the E-Mail serviceseather by pop3/imap or by using the webmail system.<p>Please <A href=\"$webmailurl\">Login</a> to read or to send emails<p>Thank you $username for joining us";}}echo "<center><p><em><font size=\"2\">Powered by <a target=\"hmail\" href=\"http://www.hmailserver.com\">HMailServer</a> @ All rights reserved</em></font></centeR>";?>[/code] Quote Link to comment Share on other sites More sharing options...
ToonMariner Posted August 22, 2006 Share Posted August 22, 2006 you need to read the imap section of the php manual matey..... Quote Link to comment Share on other sites More sharing options...
no1uno Posted August 22, 2006 Author Share Posted August 22, 2006 read the what..the where?? ???Sorry I'm not sure of your response. I would have expected changes could be made in this part of the script:[code]// Load the domain names and their ids into a variable$db = mysql_connect($dbhost, $dbuser, $dbpassword);mysql_select_db($dbname);$result = mysql_query("SELECT * FROM hm_domains WHERE domainactive = '1' ", $db);$domains = "<select name=\"domain\">";while ($row = mysql_fetch_array($result)) {$domainid = $row['domainid'];$domainname = $row['domainname'];$domains .= "\n<option value=\"$domainid\">$domainname</option>";}$domains .= "\n</select>";mysql_close();[/code] Quote Link to comment Share on other sites More sharing options...
ToonMariner Posted August 22, 2006 Share Posted August 22, 2006 you need to set up actual e-mail acounts as opposed to just a user registartion...read this section of the manual [url=http://uk.php.net/manual/en/ref.imap.php]http://uk.php.net/manual/en/ref.imap.php[/url]and more specifically this page [url=http://uk.php.net/manual/en/function.imap-createmailbox.php]http://uk.php.net/manual/en/function.imap-createmailbox.php[/url] Quote Link to comment Share on other sites More sharing options...
.josh Posted August 22, 2006 Share Posted August 22, 2006 if all you want to have as an option is one domain name, then remove the whole query to select the domain names, and the while statement that builds the vars with the data, and simply assign the domain info manually. for example, instead of $domainid = 1; //might not even need this var if you just have 1$domainname = 'blah'; Quote Link to comment Share on other sites More sharing options...
no1uno Posted August 22, 2006 Author Share Posted August 22, 2006 Thank you to all for your advise.Crayon Violent, that makes sense. I sort of figured it would be in that area, but as I am new to PHP I wasn't 100% sure.I will see how it goes.Cheers Quote Link to comment Share on other sites More sharing options...
ToonMariner Posted August 22, 2006 Share Posted August 22, 2006 Sorry I totally see where you are coming from now - I didn't look at the script just went for the jugular.... sowwie Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.