<?
session_start();
require_once('../connect/connect.php'); 
include_once('../lib/lib.php');
require('pdk.php');

if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form")) 
{
$err="";

$contakt=_pre($_POST['contakt']);
$tel=_pre($_POST['tel']);

if($contakt=="") $err = $err."Не указано контактное лицо <br>"; 
$_SESSION['ID_P'][5]=$contakt;
////////////

$email=trim($_POST['email']);
if($email=='') $err = $err."Не указан e-mail<br>";

if($email && _email($email)===false) $err = $err."Некорректный e-mail<br>";

$r = mysql_query ("SELECT * FROM akk WHERE email='".$email."' AND id_akk != '".$_SESSION['ID_P'][1]."'") or die(mysql_error());
$nr = mysql_num_rows($r);
if($nr>0) $err = $err."Пользователь с таким e-mail уже зарегистрирован<br>";

if(!empty($_POST['url']))
{
   $ns=doman_name($rru['addr']);
   $dm=doman_name($_POST['url']);
   if($ns[1]==$dm[1]) links("Недопустимый URL");
   $dm=$dm[0];
   $url="http://".$dm; 
}

if(trim($_POST['pass'])=="") $err = $err."Укажите пароль<br>";
else $pass=trim($_POST['pass']);

///////////////
if ($err=="")
	{
	mysql_query("UPDATE akk SET email='".$email."', 
	pass='".$pass."', tel='".$tel."', contakt='".$contakt."' 
	WHERE id_akk='".$_SESSION['ID_P'][1]."'");
	} 
}

$r2 = mysql_query ("SELECT * FROM akk WHERE id_akk = '".$_SESSION['ID_P'][1]."'") or die(mysql_error());
$rr2 = mysql_fetch_array($r2);
$email=$rr2['email'];
$pass=$rr2['pass'];
$tel=$rr2['tel'];
$contakt=$rr2['contakt'];
$url=$rr2['url'];


$title="Контактные данные";
$titl=$title;

require ('top.php'); 

echo "<font color=red>".$err."</font>";

?>
<form name="form" method="post" action="">
<table width="598">
<td width="140">  Контактное лицо</td>
<td width="446"> <input type="text" name="contakt" size="60" value="<? echo $contakt; ?>"></td>
</tr>


<tr>
<td>  Телефон </td>
<td> <input type="text" name="tel" size="60" value="<? echo $tel; ?>"></td>
</tr>

<tr>
<td>  E-MAIL </td> 
<td> <input type="text" name="email" size="60" value="<? echo $email; ?>"></td>
</tr>

<tr>
  <td>  Пароль </td>
  <td><input type="password" name="pass" size="60" value="<? echo $pass; ?>"></td>
</tr>

<tr>
<td>  <input class="submit" type="submit" name="Submit" value="Изменить"></td>
<td>
<input type="hidden" name="MM_insert" value="form">

</td>
</tr>
</table>
</form>
<?
require('bottom.php');
?>