-
Notifications
You must be signed in to change notification settings - Fork 0
/
slave_newUser.php
executable file
·61 lines (57 loc) · 1.78 KB
/
slave_newUser.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<?
require_once('master_validation.php');
require_once('config/connection.php');
require_once('lib/nangkoelib.php');
require_once('lib/admin_validation.php');
$uname=$_POST['uname'];
$sendmail=$_POST['sendmail'];
$pw=$_POST['pw'];
$userid=$_POST['userid'];
$active=$_POST['active'];
//Has the password
if($sendmail==1)
$email=getUserEmail($uname,$userid,$conn);
else
$email='';
if($active==1)
$ac_comment='Active';
else
$ac_comment='Inactive';
$str="insert into ".$dbname.".user (namauser,password,karyawanid,lastuser,status)
values('".$uname."',MD5('".$pw."'),".$userid.",'".$_SESSION['standard']['username']."',".$active.")";
if(mysql_query($str))
{
echo "*Account ".$uname." has been created.<br>";
//if email is available then send an email to user
if($email!='')
{
$subject='Your User Account has been created';
$content="Dear ".$uname.",<br><br>
<dd>Your Account has been created as follow:
<table>
<tr><td><i>UserName</i></td><td>:".$uname."</td></tr>
<tr><td><i>Password</i></td><td>:".$pw."</td></tr>
<tr><td><i>UserId(Empl.ID)</i></td><td>:".$userid."</td></tr>
<tr><td><i>AccountStatus</i></td><td>:".$ac_comment."</td></tr>
</table><br>
Please maintain your password periodically.
<br>
Regards,
System, at ".date('d-m-YYY H:i:s');
$from ='administrator@'.$_SERVER['HOST'].'.local';
$to =$email;
if(sendMail($subject,$content,$from,$to))
{
echo "<dd><font color=green>An announcement email has been sent to user</font><br>";
}
else
{
echo "<dd><font color=red>An announcement email was failed.</font><br>";
}
}
}
else
{
echo " Gagal,".addslashes(mysql_error($conn));
}
?>