Location: PHPKode > projects > PHPmyEXIM > email_create.php
<?php
require("session.php");
?>
<?php
if (isset($_GET['domain']))
{
	$domain = $_GET['domain'];
}
else
{
	$domain = "";
}

if($_POST['action'] == "yes")
{
	//Form-Data
	$emailaccount = $_POST['emailaccount'];
	$domain = $_POST['domain'];
	$alias1 = $_POST['alias1'];
	$alias2 = $_POST['alias2'];
	$alias3 = $_POST['alias3'];
	$alias4 = $_POST['alias4'];
	$alias5 = $_POST['alias5'];
	$alias6 = $_POST['alias6'];
	$passwort1 = $_POST['passwort1'];
	$passwort2 = $_POST['passwort2'];

	require("config.php");
	$tabelle = "mail_users";

	/* Connection to the Database */ 
	MYSQL_CONNECT($server, $user, $passw) or die ( "<H3>unable to connect to database server</H3>");
	MYSQL_SELECT_DB($datenbank) or die ( "<H3>database does not exist</H3>");

$ok = 0;
	$check=mysql_query("select mbox_name from $tabelle where mbox_name = '$emailaccount' and alias = '' and is_alias = 'no' and domain_name = '$domain'");
	$check_row = mysql_fetch_row($check);
if($check_row[0] != '')
{
	echo"<html><head><title></title>
		<link rel=stylesheet type=\"text/css\" href=\"global.css\">
		</head><body>
		<p>An eMail-account with this name already exists. Please go <br>
		<a href=\"javascript:history.back()\" target=\"main\"><img src=\"images/back.gif\" border=\"0\"></a></p>
		</body>
		</html>";
		$ok = 1;
}
else
{
	if($passwort1 != '' && $passwort2 != '' && $passwort1 == $passwort2)
		{
		$result=MYSQL_QUERY("insert into $tabelle values('$emailaccount', '$domain', '', 'no', ENCRYPT('$passwort1'), NULL, NULL, NULL, NULL)");
		if($alias1 != '')
			{
				$save_alias1=MYSQL_QUERY("insert into $tabelle values('$alias1', '$domain', '$emailaccount@$domain', 'yes', 'noaccess', NULL, NULL, NULL, NULL)");
			}else{}
		if($alias2 != '')
			{
				$save_alias2=MYSQL_QUERY("insert into $tabelle values('$alias2', '$domain', '$emailaccount@$domain', 'yes', 'noaccess', NULL, NULL, NULL, NULL)");
			}else{}
		if($alias3 != '')
			{
				$save_alias3=MYSQL_QUERY("insert into $tabelle values('$alias3', '$domain', '$emailaccount@$domain', 'yes', 'noaccess', NULL, NULL, NULL, NULL)");
			}else{}
		if($alias4 != '')
			{
				$save_alias4=MYSQL_QUERY("insert into $tabelle values('$alias4', '$domain', '$emailaccount@$domain', 'yes', 'noaccess', NULL, NULL, NULL, NULL)");
			}else{}
		if($alias5 != '')
			{
				$save_alias5=MYSQL_QUERY("insert into $tabelle values('$alias5', '$domain', '$emailaccount@$domain', 'yes', 'noaccess', NULL, NULL, NULL, NULL)");
			}else{}
		if($alias6 != '')
			{
				$save_alias6=MYSQL_QUERY("insert into $tabelle values('$alias6', '$domain', '$emailaccount@$domain', 'yes', 'noaccess', NULL, NULL, NULL, NULL)");
			}else{}		
		}else
		{
		echo"<html><head><title></title>
		<link rel=stylesheet type=\"text/css\" href=\"global.css\">
		</head><body>
		<p>The passwords you 've typed in are different. Please go<p></p>
		 <a href=\"javascript:history.back()\" target=\"main\"><img src=\"images/back.gif\" border=\"0\"></a></p>
		</body>
		</html>";
		$ok = 1;
		}
}
if ($ok == 0)
{
echo"
<html><head><title></title>
	<link rel=stylesheet type=\"text/css\" href=\"global.css\">
	</head><body>
	<p>Your eMail-Account has been created successfully.<p><a href=\"main.php?domain=$domain\" target=\"main\"><img src=\"images/home.gif\" border=\"0\"></a>
	</p>
	</body>
	</html>
";
$new_email = $emailaccount."@".$domain;
$empfanger="$new_email";
$betreff="First email";
$inhalt="This is a test-email. It creates the physically folder on the mail-server.
You can delete this email now.";
$absender    = "From:PHPmyEXIM\n";
$absender   .= "Content-Type: text/plain\n";
$absender   .= "X-Mailer: PHP ". phpversion();

@mail($empfanger, $betreff, $inhalt, $absender);
}else
{}
}
else
{
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
	<title></title>
	<link rel=stylesheet type="text/css" href="global.css">
</head>
<body> 
<form name="create_email" action="<?php echo $PHP_SELF; ?>" method="POST">
<table border="0" cellpadding="4" cellspacing="0">
<tr>
	<input type="hidden" name="action" value="yes">
	<input type="hidden" name="domain" value="<?php echo $domain; ?>">
	<th colspan="2" class="tab">Create eMail-account</th>
</tr>
<tr>
	<td class="tab1" valign="middle">eMail-adress</td>
	<td><input type="text" size="30" name="emailaccount" value="">@<?php echo $domain; ?></td>
</tr>
</table>
<p></p>
<table border="0" cellpadding="4" cellspacing="0">
<tr>
	<td class="tab1">1. Alias</td>
	<td><input type="text" size="30" name="alias1" value="">@<?php echo $domain; ?></td>
</tr>
<tr>
	<td class="tab1">2. Alias</td>
	<td><input type="text" size="30" name="alias2" value="">@<?php echo $domain; ?></td>
</tr>
<tr>
	<td class="tab1">3. Alias</td>
	<td><input type="text" size="30" name="alias3" value="">@<?php echo $domain; ?></td>
</tr>
<tr>
	<td class="tab1">4. Alias</td>
	<td><input type="text" size="30" name="alias4" value="">@<?php echo $domain; ?></td>
</tr>
<tr>
	<td class="tab1">5. Alias</td>
	<td><input type="text" size="30" name="alias5" value="">@<?php echo $domain; ?></td>
</tr>
<tr>
	<td class="tab1">6. Alias</td>
	<td><input type="text" size="30" name="alias6" value="">@<?php echo $domain; ?></td>
</tr>
</table>
<p></p>
<table border="0" cellpadding="4" cellspacing="0">
<tr>
	<td class="tab1">Password</td>
	<td><input type="password" size="30" name="passwort1" value=""></td>
</tr>
<tr>
	<td class="tab1">rewrite Password</td>
	<td><input type="password" size="30" name="passwort2" value=""></td>
</tr>
<tr>
	<td colspan="2" align="center"><input type="image" src="images/create.gif" name="submit" value="create"></td>
</tr>
</table>
</form>
</body>
</html>
<?php
}
?>
Return current item: PHPmyEXIM