ipab

Member
Oct 27, 2005
8
0
151
this is something I found on the internet that is supposed to allow me to make emails using a form, but something is going horribly wrong as it doesnt make the email. Can someone please check it out and tell me what is the problem.

Please and thank you.
 

Attachments

ipab

Member
Oct 27, 2005
8
0
151
it reports that it has made the email, but when one accesses the mail accounts in cpanel the usrname isnt there.
 

fwwebs

Well-Known Member
Feb 16, 2004
328
0
166
Set $debug=1; in the config.php to see the output.

Check out the cP Account Creator script at http://scripts.freemans-web.com. The script you're using has some of the same code as the earlier versions of cP Account Creator. The later versions have checks for duplicate entries and many more functions.
 

ipab

Member
Oct 27, 2005
8
0
151
PHP:
<?

$host="mad-skinning.net";//your url
$domain="mad-skinning.net";//your domain without the www

//Cpanel options:
$cpaneluser="blah";//your cpanel username
$cpanelpass="blah2";//your cpanel password
$cpaneltheme="x2"; //this is the word after frontend/ and the next / when you login to cpanel
$port="2083"; //this is the cpanel port

//Database options:
$dbhost="localhost"; //Usually localhost
$dbuser="blah_mail";//mysql username
$dbpass="mailtesties";//mysql password

$dbname="blah_mail";//The name of the database for mail
$dbusertbl="mailusers";//Name of the table for users
$dbadmintbl="mailadmin";//name of the table for admin


$quota="120";//how much space in kb you want to give the user
$mailurl="mail/index.php";//The url for your web based mail program
?>
PHP:
<?php
include("config.php");
if(isset($newuser))
{
$newemail = "[email protected]$domain";
$mpassword = $password2;

$link = mysql_connect($dbhost, $dbuser, $dbpass);
mysql_select_db($dbname) or die("Could not select database");
$query="SELECT username FROM $dbusertbl WHERE((username = '$newuser'))";
$result= mysql_query($query,$link);
if(mysql_num_rows($result) == 0)
{
$query="INSERT INTO $dbusertbl(name,username,password,email) VALUES ('$name','$newuser','$password1','$replymail');";
mysql_query($query,$link);
$socket = fsockopen($host,$port);
$authstr = "$cpaneluser:$cpanelpass";
$pass = base64_encode($authstr);
$in = "GET /frontend/$cpaneltheme/mail/doaddpop.html?email=$newemail&domain=$domain&password=$mpassword&quota=$quota\r\n HTTP/1.0\r\nAuthorization: Basic $pass \r\n";
fputs($socket,$in);
fclose( $socket );
?> Your account has been setup successfully please login <a href="mail/index.php">here</a>
<?
}
else {
echo "Username already in use please try another one.<br><a href=signup.php>Back</a>";
}
mysql_close($link);
}

else { ?>
<form name="orderform" method="post" action="signup.php">
<table border="0" cellspacing="1" cellpadding="0">
<tr>
<td>Your full Name:</td>
<td colspan="2"><input name="name" type="text"></td>
</tr>
<tr>
<td width="147">Other Email Address:</td>
<td colspan="2"><input name="replymail" type="text">
(In case you forget your password)</td>
</tr>
<tr>
<td>Prefered Email Address:</td>
<td colspan="2"><input name="newuser" type="text">
@<? echo($domain) ?></td>
</tr>
<tr>
<td>Password:</td>
<td colspan="2"><input name="password1" type="password"></td>
</tr>
<tr>
<td>Retype Password:</td>
<td colspan="2"><input name="password2" type="password"></td>
</tr>
<tr>
<td>&nbsp;</td>
<td colspan="2">&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td width="344"> <div align="center">
<input name="signupbtn" type="button" id="signupbtn" value="Signup" onClick="validateform()">
</div></td>
<td width="163">&nbsp;</td>
</tr>
</table>
<script language="JavaScript1.2">


function validateform()
{
if (checkEmailAddress(document.orderform.replymail))
{
if(document.orderform.password1.value == document.orderform.password2.value)
{
document.orderform.submit();
}
else
{
alert("The passwords you typed do not appear to match");
}
}
}

function checkEmailAddress(field) {
var good;
var goodEmail = field.value.match(/\b(^(\[email protected]).+((\.com)|(\.net)|(\.edu)|(\.mil)|(\.go v)|(\.org)|(\..{2,2}))$)\b/gi);

if (goodEmail){
good = true
} else {
alert('Please enter a valid e-mail address.')
field.focus()
field.select()
good = false
}
return good;
}

</script>
</form>

<? } ?>
can someone please check this over as it doesn't work for me. (i found this code on the forums)

the mysql query works, but no user is added to the pop, no errors are shown either.
 

ipab

Member
Oct 27, 2005
8
0
151
anyone? Any help would be appreciated, perhaps even testing it on your server.