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

if (isset($_GET['user']))
{
	$name = $_GET['user'];
}
else
{
	$name = "";
}

if($_POST['action'] == "yes")
{

	//Form-Data
	$name = $_POST['user'];
	$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;

//Update with no password change
if ($passwort1 == '' && $passwort2 == '')
{
//delete aliases
$del_alias=mysql_query("delete from $tabelle where alias = '$name@$domain'");

if($alias1 != '')
	{
		$save_alias1=MYSQL_QUERY("insert into $tabelle values('$alias1', '$domain', '$name@$domain', 'yes', 'noaccess', NULL, NULL, NULL, NULL)");
	}else{}
if($alias2 != '')
	{
		$save_alias2=MYSQL_QUERY("insert into $tabelle values('$alias2', '$domain', '$name@$domain', 'yes', 'noaccess', NULL, NULL, NULL, NULL)");
	}else{}
if($alias3 != '')
	{
		$save_alias3=MYSQL_QUERY("insert into $tabelle values('$alias3', '$domain', '$name@$domain', 'yes', 'noaccess', NULL, NULL, NULL, NULL)");
	}else{}
if($alias4 != '')
	{
		$save_alias4=MYSQL_QUERY("insert into $tabelle values('$alias4', '$domain', '$name@$domain', 'yes', 'noaccess', NULL, NULL, NULL, NULL)");
	}else{}
if($alias5 != '')
	{
		$save_alias5=MYSQL_QUERY("insert into $tabelle values('$alias5', '$domain', '$name@$domain', 'yes', 'noaccess', NULL, NULL, NULL, NULL)");
	}else{}
if($alias6 != '')
	{
		$save_alias6=MYSQL_QUERY("insert into $tabelle values('$alias6', '$domain', '$name@$domain', 'yes', 'noaccess', NULL, NULL, NULL, NULL)");
	}else{}		
echo"
	<html><head><title></title>
	<link rel=stylesheet type=\"text/css\" href=\"global.css\">
	</head><body>
	<p>Your changes have been saved successfully.<p><a href=\"main.php?domain=$domain\" target=\"main\"><img src=\"images/home.gif\" border=\"0\"></a></p>
	</body>
	</html>";
	$ok = 1;
}else{}

if($ok == 0)
{
//Update with password change
	if($passwort1 != '' && $passwort1 == $passwort2)
	{

//update password
$update_email=mysql_query("Update $tabelle SET password_hash = ENCRYPT('$passwort1') where mbox_name='$name' and alias = ''");

	//delete aliases
	$del_alias=mysql_query("delete from $tabelle where alias = '$name@$domain'");
	
	if($alias1 != '')
		{
			$save_alias1=MYSQL_QUERY("insert into $tabelle values('$alias1', '$domain', '$name@$domain', 'yes', 'noaccess', NULL, NULL, NULL, NULL)");
		}else{}
	if($alias2 != '')
		{
			$save_alias2=MYSQL_QUERY("insert into $tabelle values('$alias2', '$domain', '$name@$domain', 'yes', 'noaccess', NULL, NULL, NULL, NULL)");
		}else{}
	if($alias3 != '')
		{
			$save_alias3=MYSQL_QUERY("insert into $tabelle values('$alias3', '$domain', '$name@$domain', 'yes', 'noaccess', NULL, NULL, NULL, NULL)");
		}else{}
	if($alias4 != '')
		{
			$save_alias4=MYSQL_QUERY("insert into $tabelle values('$alias4', '$domain', '$name@$domain', 'yes', 'noaccess', NULL, NULL, NULL, NULL)");
		}else{}
	if($alias5 != '')
		{
			$save_alias5=MYSQL_QUERY("insert into $tabelle values('$alias5', '$domain', '$name@$domain', 'yes', 'noaccess', NULL, NULL, NULL, NULL)");
		}else{}
	if($alias6 != '')
		{
			$save_alias6=MYSQL_QUERY("insert into $tabelle values('$alias6', '$domain', '$name@$domain', 'yes', 'noaccess', NULL, NULL, NULL, NULL)");
		}else{}		
	echo"
	<html><head><title></title>
	<link rel=stylesheet type=\"text/css\" href=\"global.css\">
	</head><body>
	<p>Your changes have been saved successfully.<p><a href=\"main.php?domain=$domain\" target=\"main\"><img src=\"images/home.gif\" border=\"0\"></a></p>
	</body>
	</html>";
	}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 <a href=\"javascript:history.back()\" target=\"main\"><img src=\"images/back.gif\" border=\"0\"></a></p>
	</body>
	</html>";
	}
}else
{}
}
else
{
	require("config.php");
	$tabelle = "mail_users";

	/* Connection to the Database */ 
	MYSQL_CONNECT($server, $user, $passw) or die ( "<H3>Datenbankserver nicht erreichbar</H3>");
	MYSQL_SELECT_DB($datenbank) or die ( "<H3>Datenbank nicht vorhanden</H3>");

	$result1=MYSQL_QUERY("select mbox_name, domain_name from $tabelle where domain_name='$domain' and mbox_name='$name'");
	$row1 = mysql_fetch_row($result1);
?>
<!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" align="center">
<tr>
	<input type="hidden" name="action" value="yes">
	<input type="hidden" name="domain" value="<?php echo $domain; ?>">
	<input type="hidden" name="user" value="<?php echo $name; ?>">
	<th colspan="2" class="tab">Edit eMail-account</th>
</tr>
<tr>
	<td class="tab1" valign="middle">eMail-adress:</td>
	<td><i><?php echo $row1[0]?>@<?php echo $domain; ?></i></td>
</tr>
</table>
<p></p>
<table border="0" cellpadding="4" cellspacing="0" align="center">
<?php
	require("config.php");
	$tabelle = "mail_users";

	/* Connection to the Database */ 
	MYSQL_CONNECT($server, $user, $passw) or die ( "<H3>Datenbankserver nicht erreichbar</H3>");
	MYSQL_SELECT_DB($datenbank) or die ( "<H3>Datenbank nicht vorhanden</H3>");

	$alias11=MYSQL_QUERY("select mbox_name from $tabelle where alias = '$name@$domain'");
$i = 1;
while($row11 = mysql_fetch_row($alias11))
{
echo"<tr>
	<td class=\"tab1\">$i. Alias</td>
	<td><input type=\"text\" size=\"30\" name=\"alias$i\" value=\"$row11[0]\">@$domain</td>
</tr>";
$i++;
}

for($i; $i<=6; $i++)
{
echo"<tr>
	<td class=\"tab1\">$i. Alias</td>
	<td><input type=\"text\" size=\"30\" name=\"alias$i\" value=\"\">@$domain</td>
</tr>";
}
?>
</table>
<p></p>
<table border="0" cellpadding="4" cellspacing="0" align="center">
<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/change.gif" name="submit" value="change"></td>
</tr>
</table>
</form>
</body>
</html>
<?php
}
?>
Return current item: PHPmyEXIM