<?php
foreach ($_REQUEST as $k=>$v) {
		${$k} = $v;
	}
?>

<script language="javascript" type="text/JavaScript">

function Check(form) {
	missinginfo = "";
	<?php 
	if(!isset($_SESSION["member_id"])){
		?>
		if ((form.shipmail.value.length < 4) || 
		(form.shipmail.value.indexOf('@') == -1) || 
		(form.shipmail.value.indexOf('.') == -1)) {
			missinginfo += "\n     -  Email address";
		}
		if ((form.shipmail.value.indexOf('\'') >0) || (form.shipmail.value.indexOf('\"') >0)) {
			missinginfo += "\n     -  Member Email address should not have apostrophes";
		}
		<?php 
	}
	?>
	
	if (form.shipname.value.length < 1) {
		missinginfo += "\n     -  First Name";
	}
	
	if (form.shipsurname.value.length < 1) {
	missinginfo += "\n     -  Last Name";
	}
	if (form.shiptel.value.length < 4) {
	missinginfo += "\n     -  Telephone";
	}
	if (form.shipdistrict.value == "") {
	missinginfo += "\n     -  District";
	}
	if (form.shipcity.value == "") {
	missinginfo += "\n     -  Town/Village";
	}
	if (form.shipaddress1.value == "") {
	missinginfo += "\n     -  Address Line 1";
	}
	if (form.shipzip.value == "") {
	missinginfo += "\n     -  Postal Code";
	}
	if (missinginfo != "") {
	missinginfo ="_____________________________\n" +
	"You failed to correctly fill in your:\n" +
	missinginfo + "\n_____________________________" +
	"\nPlease re-enter and submit again!";
	alert(missinginfo);
	return false;
	}
}
</script>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
              <tr> 
                <td height=10 width=10><img height=10 
                  src="<?=$path;?>images/navigation/featured_box/box_1.gif" width=10></td>
                <td background="<?=$path;?>images/navigation/featured_box/box_top.gif"></td>
                <td width=10><img height=10 
                  src="<?=$path;?>images/navigation/featured_box/box_2.gif" width=12></td>
              </tr>
              <tr> 
                <td background="<?=$path;?>images/navigation/featured_box/box_left.gif"></td>
                <td align="center" valign=top> <table width="100%" border="0" cellspacing="0" cellpadding="0">
                    <tr> 
                      <td valign="top"><TABLE Align="Center" Width="100%" BORDER="0" CellPadding="5" CellSpacing="1">
                          <tr> 
                            <td><?php if(isset($_SESSION["member_id"])) {
                            	?> <?php if(isset($submit)){$result=mysql_query("SELECT * FROM members WHERE member_id='$_SESSION[member_id]'");
$lineprevious=mysql_fetch_array($result);
$table="members";
$id="member_id";
$rows_array= array ("shipname", "shipsurname", "companyname", "password", "shiptel", "shipfax", "shipdistrict", "shiparea", "shipcity", "shipdistrict_id", "shiparea_id", "shipcity_id", "shipaddress1", "shipaddress2", "shipzip", "billname", "billsurname", "billmail", "billtel", "billfax", "billaddress1", "billaddress2", "billdistrict", "billarea", "billcity", "register", "billcountry", "billzip", "shipmobile", "billmobile");
if(isset($password) && $password<>""){
	if($password==$lineprevious["password"]){
		if($newpassword==$newpassword2 && strlen($newpassword)>=6){
			$password=$newpassword;
			echo "<b style='color: #990000;'>Password changed successfully.</b><br>";
		}else{
			echo "<b style='color: #990000;'>Passwords <u>do not match</u> or <u>less than 6 characters</u></b><br>";
			$password=$lineprevious["password"];
		}
	}
	else{
		echo "<b style='color: #990000;'>You have entered an <u>Incorrect Password</u></b><br>";
		$password=$lineprevious["password"];

	}

}else{$password=$lineprevious["password"];}

$rows="";

$variables="";

for ($i=0;$i<=(count($rows_array)-2);$i++){

$rows .=$rows_array[$i];

$rows .="=";

$rows .="'";

$rows .=$$rows_array[$i];

$rows .="'";

$rows .=", ";

}

$rows .=$rows_array[count($rows_array)-1];

$rows .="=";

$rows .="'";

$rows .=$$rows_array[count($rows_array)-1];

$rows .="'";

$query2 = "UPDATE $table SET $rows WHERE $id='${$id}'";

$result2 = mysql_query ($query2)

or die (mysql_error());

echo "<b style='color: #990000;'>Changes have been made successfully.</b>";}?>

<?php $querymembers = "SELECT * FROM members WHERE member_id='{$_SESSION['member_id']}'";

			$resultmembers = mysql_query ($querymembers);

			$linemembers=mysql_fetch_array($resultmembers);?>

<form action="account/my_info.html" method="post" name="ThisForm" id="ThisForm" onSubmit="return Check(ThisForm);">

					<TABLE id="articleX" height="100%" cellSpacing="1" cellPadding="1" width="100%" border="0">
						<TBODY>
							<TR>
								<TD vAlign="top">
									<h1>Change account details </h1>
									<p>You may change your account details  in the following form.</p>
									<p>Fields marked with an asterisk * are required.</p>
								</TD>
							</TR>
						</TBODY>
					</TABLE>


                    <table border="0" cellpadding="3" cellspacing="2">

                                <tr>

                                  <td width="150" align="right" nowrap>&nbsp; </td>
								  
                                </tr>

                                <tr>

                                  <td align="right" class="left">E-mail:</td>

                                  <td colspan="2" nowrap class="right"><strong><?=$linemembers["shipmail"];?></strong> </td>

                                </tr>

                                <tr>

                                  <td align="right">Old Password </td>

                                  <td colspan="2" class="linkGenreLeft"><input name="password" type="password" class="input" id="password" value="" size="30" maxlength="120"></td>

                                </tr>

                                <tr>

                                  <td align="right">New Password</td>

                                  <td colspan="2" class="linkGenreLeft"><input name="newpassword" type="password" class="input" id="newpassword" size="30" maxlength="120">

    6 characters and more </td>

                                </tr>

                                <tr>

                                  <td align="right">Confirm Password </td>

                                  <td colspan="2"><span class="linkGenreLeft">

                                    <input name="newpassword2" type="password" class="input" id="newpassword2" size="30" maxlength="120">

                                  </span></td>

                                </tr>

                                <tr>

                                  <td align="right" class="left">First Name:</td>

                                  <td colspan="2" class="right"><input name="shipname" type="text" class="input" id="shipname" value="<?=$linemembers["shipname"];?>" size="30" maxlength="80">

        * </td>

                                </tr>

                                <tr>

                                  <td align="right" class="left"> Middle Name:</td>

                                  <td colspan="2" class="right"><input name="billname" type="text" class="input" id="billname" value="<?=$linemembers["billname"];?>" size="30">

                                  </td>

                                </tr>

                                <tr>

                                  <td align="right" class="left">Last Name:</td>

                                  <td colspan="2" class="right"><input name="shipsurname" type="text" class="input" id="shipsurname" value="<?=$linemembers["shipsurname"];?>" size="30" maxlength="80">

        * </td>

                                </tr>

                                <tr>
                                  <td align="right" class="left">Company</td>
                                  <td colspan="2" class="right"><input name="companyname" type="text" class="input" id="companyname" value="<?=$linemembers["companyname"];?>" size="30" maxlength="80"></td>
                                </tr>
                                <tr>

                                  <td align="right" class="left">Telephone:</td>

                                  <td colspan="2" class="right"><input name="shiptel" type="text" class="input" id="shiptel" value="<?=$linemembers["shiptel"];?>" size="30" maxlength="30">

        * </td>

                                </tr>

                                <tr>

                                  <td align="right" class="left">Mobile:</td>

                                  <td colspan="2" class="right"><input name="shipmobile" type="text" class="input" id="shipmobile" value="<?=$linemembers["shipmobile"];?>" size="30" maxlength="30"></td>

                                </tr>

                                <tr>

                                  <td align="right" class="left">Fax:</td>

                                  <td colspan="2" class="right"><input name="shipfax" type="text" class="input" id="shipfax" value="<?=$linemembers["shipfax"];?>" size="30" maxlength="30">

                                  </td>

                                </tr>

                                <tr>

                                  <td align="right" class="left">Business Phone: </td>

                                  <td colspan="2" class="right"><input name="billtel" type="text" class="input" id="billtel" value="<?=$linemembers["billtel"];?>" size="30">

                                  </td>

                                </tr>

                                <TR>

                                  <TD align=right valign=middle class="left"> District: </td>

                                  <td class="right"> <span class="moreInfo">

                                    <?php $querydistricts = "SELECT * FROM  districts WHERE active='yes' ORDER BY order_seq ASC";

			$resultdistricts = mysql_query ($querydistricts);

			if (mysql_num_rows($resultdistricts) <> 0){?>

                                    <select name="shipdistrict" id="shipdistrict">

                                      <option value="" selected>None</option>

                                      <?php while($linedistricts = mysql_fetch_array($resultdistricts)){?>

                                      <option value="<?=$linedistricts["title_en"];?>"<?php if($linedistricts["title_en"]==$linemembers["shipdistrict"]){echo " selected";}?>>

                                      <?=$linedistricts["title_en"]; ?>

                                      </option>

                                      <?php }?>

                                    </select>

                                    <?php }else{?>

        No districts added yet.

        <?php }?>

        * </span> <span class="red"> </span> </td>

                                  <td rowspan="3" class="right"><span class="linkGenreLeft"> </span></td>

                                </tr>

                                <TR>

                                  <TD align=right valign=middle class="left">Area:</td>

                                  <td nowrap class="right">

                                    <input name="shiparea" type="text" class="input" id="shiparea" value="<?=$linemembers["shiparea"];?>" size="30"></td>

                                </tr>

                                <TR>

                                  <TD align=right valign=middle class="left">Town/Village:</td>

                                  <td nowrap class="right">

                                    <input name="shipcity" type="text" class="input" id="shipcity" value="<?=$linemembers["shipcity"];?>" size="30">

        * </td>

                                </tr>

                                <tr>

                                  <td align="right" class="left">P. O. BOX:</td>

                                  <td colspan="2" class="right"><input name="billaddress1" type="text" class="input" id="billaddress1" value="<?=$linemembers["billaddress1"];?>" size="30">

                                      <span class="red"> </span></td>

                                </tr>

                                <tr>

                                  <td align="right" class="left">Address line 1:</td>

                                  <td colspan="2" class="right"><input name="shipaddress1" type="text" class="input" id="shipaddress1" value="<?=$linemembers["shipaddress1"];?>" size="30" maxlength="80">

        * </td>

                                </tr>

                                <tr>

                                  <td align="right" class="left">Address line 2:</td>

                                  <td colspan="2" class="right"><input name="shipaddress2" type="text" class="input" id="shipaddress2" value="<?=$linemembers["shipaddress2"];?>" size="30" maxlength="80">

                                  </td>

                                </tr>

                                <tr>

                                  <td align="right" class="left">Postal code:</td>

                                  <td colspan="2" class="right"><input name="shipzip" type="text" class="input" id="shipzip" value="<?=$linemembers["shipzip"];?>" size="5" maxlength="5">

        * </td>

                                </tr>

                                <tr>

                                  <td align="right" class="left"><span class="right">

                                    <input name="module_page" type="hidden" id="module_page" value="account">
                                    <input name="account_url" type="hidden" id="account_url" value="my_info">

                                    <input name="domain_id" type="hidden" id="domain_id" value="<?php echo $linemembers["domain_id"];?>">

                                    <input name="register" type="hidden" id="register" value="yes">

                                  </span></td>

                                  <td colspan="2" class="right"><input name="submit" type="submit" id="submit" value="Submit"></td>

                                </tr>

                                <tr>

                                  <td align="right" class="left">* Required Fields </td>

                                  <td colspan="2" class="right">&nbsp;</td>

                                </tr>

                              </table>

            <p>                                <BR>

                    </p>
								<input type="hidden" name="module_page" value="account"/>
								<input name="account_url" type="hidden" id="account_url" value="my_info"/>
                              </form>                              
                              <?php 
                            }
                              else{

if(1==1) {                              
//echo "SELECT shipmail FROM members WHERE shipmail='$shipmail'";
	   	
$result=mysql_query("SELECT shipmail FROM members WHERE shipmail='$shipmail'");

$NumberOfFields=mysql_num_rows($result);

if ($NumberOfFields == 0 && isset($submit)){

$table="members";

$id="member_id";

$rows_array= array ("shipname", "shipsurname", "shipmail", "companyname", "password", "shiptel", "shipfax", "shipdistrict", "shiparea", "shipcity", "shipdistrict_id", "shiparea_id", "shipcity_id", "shipaddress1", "shipaddress2", "shipzip", "billname", "billsurname", "billmail", "billtel", "billfax", "billaddress1", "billaddress2", "billdistrict", "billarea", "billcity", "register", "confirmed", "date_added", "billcountry", "billzip", "period", "shipmobile", "billmobile", "catdom_id");

include($general_path . "passgen.php");

include($general_path . "config_mail.php");

$password = random_string($charset, 8);

$date_added=date("Y-m-d");

$confirmed="no";

$catdom_id=$domain_id;

$register="yes";

if(!isset($enable_adult) || $enable_adult==""){$enable_adult="no";}else{

	$adult_code = random_string($charset, 8);

}

$rows="";

$variables="";

for ($i=0;$i<=(count($rows_array)-2);$i++){

$rows .=$rows_array[$i];

$variables .="'";

$variables .=$$rows_array[$i];

$variables .="'";

$rows .=", ";

$variables .=", ";

}

$rows .=$rows_array[count($rows_array)-1];

$variables .="'";

$variables .=$$rows_array[count($rows_array)-1];

$variables .="'";

$query1 = "INSERT INTO $table ($rows) VALUES ($variables)";

$result1 = mysql_query ($query1)

or die (mysql_error());

$member_ID=mysql_insert_id();

$headers  = "MIME-Version: 1.0\r\n";

$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";

/* additional headers */

$headers .= "From: ";

$headers .= $from;

$headers .= "\r\n";

$subject="Welcome CyprusNet";

$message="Username=$shipmail<br>Password=$password";

if($enable_adult=="yes"){

	$message .="<br>Adult code:$adult_code";

}

mail($shipmail, $subject, $message, $headers);

?>              <table width="100%"  border="0" cellspacing="2" cellpadding="2">

  <tr>

    <td>Your sign up was successful. Please login when you receive your password on your e-mail account <span  class="darkBlueBold">&quot;<?=$shipmail;?>&quot;</span>. </td>

  </tr>

</table><?php } else{?>

<?php if ($NumberOfFields <> 0 && isset($_REQUEST['shipmail']) ){
	
	
	
	?>

<table width="100%"  border="0" cellspacing="2" cellpadding="2">

  <tr>

    <td>The e-mail address you have entered <span class="movieTitle">already exists</span> in our member's list. Please use another e-mail address or <a href="account/forgot.html" class="small10" >request</a> your password to be sent to your e-mail if you have forgotten it.

 </td>

  </tr>

</table><?php }?> <form action="account/my_info.html" method="post" name="ThisForm" id="ThisForm" onSubmit="return Check(ThisForm);">

								<TABLE id=articleX height="100%" cellSpacing=1 cellPadding=1 width="100%" border=0>
									<TBODY>
										<TR>
											<TD vAlign=top>
												<h1>Sign Up</h1>
												<p>To become a member of the Cyprus Network please fill in the following form.</p>
												<p>Fields marked with an asterisk * are required.</p>
											</TD>
										</TR>
									</TBODY>
								</TABLE>


                                <table border="0" cellpadding="3" cellspacing="2">

                                  <tr>

                                    <td width="150" align="right" nowrap>&nbsp; </td>

                                  </tr>

                                  <tr>

                                    <td align="right" class="left">E-mail:</td>

                                    <td colspan="2" nowrap class="right"><input name="shipmail" type="text" class="input" id="shipmail" size="30" maxlength="80">

                                        <span class="linkGenreLeft"> <span class="red">* </span></span>(will be used as username) <span class="small"> </span></td>

                                  </tr>

                                  <tr>

                                    <td align="right" class="left">First Name:</td>

                                    <td colspan="2" class="right"><input name="shipname" type="text" class="input" id="shipname" value="<?=$shipname;?>" size="30" maxlength="80"> 

                                      * </td>

                                  </tr>

                                  <tr>

                                    <td align="right" class="left"> Middle Name:</td>

                                    <td colspan="2" class="right"><input name="billname" type="text" class="input" id="billname" value="<?=$billname;?>" size="30">                                      <span class="red"> </span></td>

                                  </tr>

                                  <tr>

                                    <td align="right" class="left">Last Name:</td>

                                    <td colspan="2" class="right"><input name="shipsurname" type="text" class="input" id="shipsurname" value="<?=$shipsurname;?>" size="30" maxlength="80"> 

                                      *

                                    </td>

                                  </tr>
                                  <tr>
                                    <td align="right" class="left">Company:</td>
                                    <td colspan="2" class="right"><input name="companyname" type="text" class="input" id="companyname" value="<?=$companyname;?>" size="30" maxlength="80">
    </td>
                                  </tr>

                                  <tr>

                                    <td align="right" class="left">Telephone:</td>

                                    <td colspan="2" class="right"><input name="shiptel" type="text" class="input" id="shiptel" value="<?=$shiptel;?>" size="30" maxlength="30"> 

                                      *

                                    </td>

                                  </tr>

                                  <tr>

                                    <td align="right" class="left">Mobile:</td>

                                    <td colspan="2" class="right"><input name="shipmobile" type="text" class="input" id="shipmobile" value="<?=$shipmobile;?>" size="30" maxlength="30"></td>

                                  </tr>

                                  <tr>

                                    <td align="right" class="left">Fax:</td>

                                    <td colspan="2" class="right"><input name="shipfax" type="text" class="input" id="shipfax" value="<?=$shipfax;?>" size="30" maxlength="30">

                                    </td>

                                  </tr>

                                  <tr>

                                    <td align="right" class="left">Business Phone: </td>

                                    <td colspan="2" class="right"><input name="billtel" type="text" class="input" id="billtel" value="<?=$billtel;?>" size="30">

                                    </td>

                                  </tr>

                                  <TR>

                                    <TD align=right valign=middle class="left"> District: </td>

                                    <td class="right"> <span class="moreInfo">

                                      <?php $querydistricts = "SELECT * FROM  districts WHERE active='yes' ORDER BY order_seq ASC";

			$resultdistricts = mysql_query ($querydistricts);

			if (mysql_num_rows($resultdistricts) <> 0){?>

                                      <select name="shipdistrict" id="shipdistrict">

                                        <option value="" selected>None</option>

                                        <?php while($linedistricts = mysql_fetch_array($resultdistricts)){?>

                                        <option value="<?=$linedistricts["title_en"];?>"<?php if($linedistricts["title_en"]==$shipdistrict){echo " selected";}?>>

                                        <?=$linedistricts["title_en"]; ?>

                                        </option>

                                        <?php }?>

                                      </select>

                                      <?php }else{?>

      No districts added yet.

      <?php }?> *

                                    </span> <span class="red"> </span> </td>

                                    <td rowspan="3" class="right"><span class="linkGenreLeft"> </span></td>

                                  </tr>

                                  <TR>

                                    <TD align=right valign=middle class="left">Area:</td>

                                    <td nowrap class="right">

                                      <input name="shiparea" type="text" class="input" id="shiparea" value="<?=$shiparea;?>" size="30"> 

                                      </td>

                                  </tr>

                                  <TR>

                                    <TD align=right valign=middle class="left">Town/Village:</td>

                                    <td nowrap class="right">

                                      <input name="shipcity" type="text" class="input" id="shipcity" value="<?=$shipcity;?>" size="30">

*                                     </td>

                                  </tr>

                                  <tr>

                                    <td align="right" class="left">P. O. BOX:</td>

                                    <td colspan="2" class="right"><input name="billaddress1" type="text" class="input" id="billaddress1" value="<?=$billaddress1;?>" size="30">

                                        <span class="red"> </span></td>

                                  </tr>

                                  <tr>

                                    <td align="right" class="left">Address line 1:</td>

                                    <td colspan="2" class="right"><input name="shipaddress1" type="text" class="input" id="shipaddress1" value="<?=$shipaddress1;?>" size="30" maxlength="80">

*                                     </td>

                                  </tr>

                                  <tr>

                                    <td align="right" class="left">Address line 2:</td>

                                    <td colspan="2" class="right"><input name="shipaddress2" type="text" class="input" id="shipaddress2" value="<?=$shipaddress2;?>" size="30" maxlength="80">

                                    </td>

                                  </tr>

                                  <tr>

                                    <td align="right" class="left">Postal code:</td>

                                    <td colspan="2" class="right"><input name="shipzip" type="text" class="input" id="shipzip" value="<?=$shipzip;?>" size="5" maxlength="5">

*                                     </td>

                                  </tr>

                                  <tr>

                                    <td align="right" class="left"><span class="right">

                                      <input name="module_page" type="hidden" id="module_page" value="account">
                                      <input name="account_url" type="hidden" id="account_url" value="my_info">

                                      <input name="domain_id" type="hidden" id="domain_id2" value="<?php echo $domain_id;?>">

                                      <input name="register" type="hidden" id="register2" value="yes">

                                    </span></td>

                                    <td colspan="2" class="right"><input type="submit" value="Sign Up" name="submit"></td>

                                  </tr>

                                  <tr>

                                    <td align="right" class="left">* Required Fields </td>

                                    <td colspan="2" class="right">&nbsp;</td>

                                  </tr>

                                </table>

                      <p>&nbsp;</p>

                                <p><br>

                                  <BR>

                              </p>
                            </form>
                            <?php 
		}
	}
}
?></td>

                          </tr>

                        </Table></td>

                    </tr>

                  </table></td>

                <td background="<?=$path;?>images/navigation/featured_box/box_right.gif"></td>

              </tr>

              <tr> 

                <td height=12 width=10><img height=12 src="<?=$path;?>images/navigation/featured_box/box_3.gif" width=10></td>

                <td background="<?=$path;?>images/navigation/featured_box/box_bot.gif"></td>

                <td><img height=12 src="<?=$path;?>images/navigation/featured_box/box_4.gif" 

                  width=12></td>

              </tr>

</table>
<?php

?>