<?php

session_name("SIGNADMAUTH");
session_start();

include "common/config/config.php";
include "common/config/dbconfig.php";
include "common/functions/funcconnect.php";
openDB();

include "common/functions/funcselectdb.php";
include "common/functions/funcauthen.php";
include "common/functions/funcauthen.php";

if (!authen())
{ header ("location: login.php");
		}
else
{ $iduser=isset($_SESSION['SES_USERID']) ? cleanval($_SESSION['SES_USERID']) : NULL;
		$email=isset($_POST['email']) ? cleanval($_POST['email']) : NULL;
		
		if (empty($email))
		{	$msg="Alamat email baru tidak boleh kosong.<br><br>".$linkback;
				}
		else
		{ $que="UPDATE $db_appuser
										SET useremail='".$email."' 
										WHERE userid='".$iduser."'
										";
				$rue=mysqli_query($dbConnection, $que);
				if ($rue)
				{ $msg="Mengubah alamat email sukses.";
						$logdesc="UPDATE ALAMAT EMAIL";
						include "logakses.php";
						}
				else
				{ $msg="Mengubah alamat email gagal.<br><br>".$linkback;
						}
				}
		}

$content="<table border='0' cellpadding='6px' cellspacing='0' width='100%'>
											<tr>
												<td align='left' valign='top' width='100%'>
													<b class='title'>My Account &gt; Ubah Alamat Email</b>
													<br><hr size='1' color='#000000'><br>
													<table border='0' cellpadding='0' cellspacing='0'>
														<tr>
															<td align='left' valign='top'>
																".$msg."
															</td>
														</tr>
													</table>		
												</td>
											</tr>
										</table>
										";

include "webmenu.php";
include "common/include/template.php";
$temp=new template;
$temp->define_theme("themes/theme1.html");
$temp->define_tag("{PAGETITLE}", $namaaplikasi);
$temp->define_tag("{NAMAUSER}", strtoupper($_SESSION['SES_FULLNAME']));
$temp->define_tag("{APPMENU}", $webmenu);
$temp->define_tag("{APPCONTENT}", $content);
$temp->parse();
$temp->printproses();

closeDB();

?>