home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
csi.uticak12.org
/
csi.uticak12.org.tar
/
csi.uticak12.org
/
back
/
profile.php
< prev
next >
Wrap
PHP Script
|
2011-10-20
|
5KB
|
164 lines
<?
include 'guard.php';
$act=$_REQUEST['act'];
$err=$_REQUEST['err'];
$newuname=$_REQUEST['newuname'];
$mail=$_REQUEST['mail'];
$oldpass=$_REQUEST['oldpass'];
$newupass=$_REQUEST['newupass'];
$cpass=$_REQUEST['cpass'];
mysql_connect(HostName,UserName,Password) or die("<html><body>Can not connect to MySql server!<br></body></html>");
mysql_select_db (DBName) or die ("<html><body>Could not select database ".DBName."<br></body></html>");
if(IntVal($act)==1){
if(Strval($admpass)==Strval($oldpass)){
if (isset($newuname)) {
if (trim($newupass)=="") {mysql_query("update gal_admin set Alogin='".addslashes(($newuname))."', Aemail='".addslashes(($mail))."'");};
if (trim($newupass)!="") {
if (trim($newupass)==trim($cpass)) {
mysql_query("update gal_admin set Alogin='".addslashes(($newuname))."', Apassword='".addslashes(($newupass))."', Aemail='".addslashes(($mail))."'"); $_SESSION["admpass"]=$newupass; }
else
{
echo '<script>location.href="profile.php?err=1"</script>';
};
};
$_SESSION["admname"]=$newuname;
echo '<script>location.href="profile.php?err=2"</script>';
exit;
}else{
echo '<script>location.href="profile.php?err=1"</script>';
exit;
}
}else{
echo '<script>location.href="profile.php?err=3"</script>';
exit;
}
}
else
{
$res=mysql_query ("SELECT * FROM gal_admin");
$f=mysql_fetch_array ($res);
$a_name=$f['Alogin'];
$a_mail=$f['Aemail'];
};
?>
<script language="JavaScript">
function trim(s1) {
var s=new String(s1);
while ((s.length>0) && (s.charAt(s.length-1)==" "))
s = s.substr(s,s.length-1);
return s;
}
function form_valid() {
if (trim(document.form1.newuname.value)==""){
alert("User name field cannot be empty!");
return false;
}
if (trim(document.form1.mail.value)==""){
alert("Mail field cannot be empty!");
return false;
}
if (trim(document.form1.newuname.value).length<3){
alert("Incorrect username!");
return false;
}
if (trim(document.form1.oldpass.value)=="" || trim(document.form1.newupass.value)=="" || trim(document.form1.cpass.value)==""){
alert("All fields are required!");
return false;
}
if (trim(document.form1.oldpass.value).length<3 || trim(document.form1.newupass.value).length<3 || trim(document.form1.cpass.value).length<3){
alert("Incorrect password!");
return false;
}
var s = new String(trim(document.form1.oldpass.value));
if (s.match(/[^0-9a-zA-Z]/)) {
alert("Wrong old password!");
return false;
}
if (document.form1.newupass.value!=document.form1.cpass.value){
alert("Wrong confirmation of password!\nPlease, try again!!");
return false;
}
var s = new String(trim(document.form1.newuname.value));
if (s.match(/[^0-9a-zA-Z]/)) {
alert("Wrong username!");
return false;
}
var s = new String(trim(document.form1.newupass.value));
if (s.match(/[^0-9a-zA-Z]/)) {
alert("Wrong new password!");
return false;
}
}
</script>
<? $header = "Change My Profile";
include ('top.inc'); ?>
<?php if (isset($err) and IntVal($err)==1){?>
<h1 align='center'class="maintxt">Wrong password confirmation! Please, try again!</font></h1>
<?php }?>
<?php if (isset($err) and IntVal($err)==2){?>
<h1 align='center' class="maintxt">Administrator's details have been changed!</font></h1>
<?php }?>
<?php if (isset($err) and IntVal($err)==3){?>
<h1 align='center' class="maintxt">Old password is wrong!</font></h1>
<?php }?>
<form name="form1" method="post" action="profile.php">
<table border=0 cellspacing=0 cellpadding=5 align=center width="100%">
<tr>
<td class="border">
<table border=0 cellspacing=1 cellpadding=5 width="100%" class="back">
<tr>
<td class="th" colspan=2><p align="center">All fields marked * are required!<br>Fields marked ** are required while password is changing! </p></td>
</tr>
<tr>
<td class="odd" align=right><b>Username:</b></td>
<td class="odd"><input type=text size=30 class="inp" name="newuname" value="<? echo $a_name; ?>"></td>
</tr>
<tr>
<td class="even" align=right><b>E-mail address:</b></td>
<td class="even"><input type=text size=30 class="inp" name="mail" value="<? echo $a_mail; ?>"></td>
</tr>
<tr>
<td class="odd" align=right><b>Old password *:</b></td>
<td class="odd"><input type=password size=30 class="inp" name="oldpass"></td>
</tr>
<tr>
<td class="even" align=right><b>New password **:</b></td>
<td class="even"><input type=password size=30 class="inp" name="newupass"></td>
</tr>
<tr>
<td class="odd" align=right><b>Re-enter new password **:</b></td>
<td class="odd"><input type=password size=30 class="inp" name="cpass"></td>
</tr>
<tr>
<td class="tf" colspan=2 align=center>
<input type=submit value="Update" class="btn">
<!-- <input type=button value="Cancel" class="btn" onClick ="location.href='home.php'">-->
</td>
</tr>
</table>
</td>
</tr>
</table>
<input type="hidden" name="act" value="1">
</form>
<? include ('btm.inc'); ?>