Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
PA1
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Michael Ollifarel Sagala
PA1
Commits
2f43bf4a
Commit
2f43bf4a
authored
Jan 11, 2020
by
Michael Ollifarel Sagala
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
versi 2
parent
5d66d3ab
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
141 additions
and
9 deletions
+141
-9
edit_profile.php
edit_profile.php
+8
-1
fungsi.php
fungsi.php
+122
-5
profile.php
profile.php
+5
-0
register.php
register.php
+5
-2
test.php
test.php
+1
-1
No files found.
edit_profile.php
View file @
2f43bf4a
...
...
@@ -2,12 +2,13 @@
session_start
();
include_once
'fungsi.php'
;
$ok
=
new
data
();
$subm
=
new
SudahLogin
();
if
(
isset
(
$_GET
[
'status'
])){
$ok
->
logout
();
}
$temp
=
$_SESSION
[
'id'
];
if
(
isset
(
$_POST
[
'SubmitEditProfile'
])){
$
ok
->
EditDataProfile
(
$_POST
[
'nama'
],
$_POST
[
'marga'
],
$_POST
[
'beibe'
],
$_POST
[
'kelamin'
],
$_POST
[
'prodi'
],
$_POST
[
'angkatan'
],
$_POST
[
'id
'
]);
$
subm
->
EditDataProfile
(
$_POST
[
'nama'
],
$_POST
[
'marga'
],
$_POST
[
'beibe'
],
$_POST
[
'Jenis_kelamin'
],
$_POST
[
'prodi'
],
$_POST
[
'angkatan'
],
$_POST
[
'id'
],
$_POST
[
'kelas
'
]);
}
?>
...
...
@@ -112,6 +113,12 @@
</select>
</h3></td>
</tr>
<tr>
<td><h3>
Kelas
</h3></td>
<td><h3>
:
</h3></td>
<td><h3>
<input
class=
"w3-input w3-border"
name=
"kelas"
type=
"text"
placeholder=
"
<?php
$d
=
$ok
->
Editprofile
(
$temp
,
'kelas'
);
echo
$d
;
?>
"
></h3></td>
</tr>
<tr>
<td><h3>
Prodi
</h3></td>
<td><h3>
:
</h3></td>
...
...
fungsi.php
View file @
2f43bf4a
...
...
@@ -51,22 +51,45 @@
}
}
function
register
(
$id
,
$pass
,
$gend
){
function
Testregister
(
$username
,
$pass
,
$gend
){
$check
=
$this
->
conn
()
->
query
(
"SELECT COUNT(*) as hitung FROM user where username like '
$username
'"
);
$data
=
mysqli_fetch_assoc
(
$check
);
$sipla
=
$data
[
'hitung'
];
if
(
$sipla
>
0
){
header
(
'Location: register.php?alert=true'
);
}
else
{
$this
->
register
(
$username
,
$pass
,
$gend
);
// echo "ga ada";
}
}
function
register
(
$username
,
$pass
,
$gend
){
if
(
$gend
==
'L'
){
$ok
=
1
;
}
else
{
$ok
=
2
;
}
$ok
=
2
;
// $id = 100;
$nama
=
"Not Set"
;
$notset
=
8
;
$ab
=
"Not Set"
;
$gender
=
3
;
$angkatan
=
0
;
$prodi
=
"Not Set"
;
// echo $ok;
if
(
mysqli_query
(
$this
->
conn
(),
"INSERT INTO `user` VALUES (NULL, '
$id
', '
$pass
', '2')"
)){
if
(
mysqli_query
(
$this
->
conn
(),
"INSERT INTO `data_user` VALUES (NULL, '
$id
', 'aahhhh', '
$notset
', '
$notset
', 'ab', '
$angkatan
', 'ab', '
$ok
')"
)){
echo
" bisa"
;
if
(
mysqli_query
(
$this
->
conn
(),
"INSERT INTO `user` VALUES (NULL, '
$username
', '
$pass
', '2')"
)){
$check
=
$this
->
conn
()
->
query
(
"SELECT * from user where username='
$username
'"
);
$d
=
mysqli_fetch_array
(
$check
);
$ID
=
$d
[
'id'
];
if
(
mysqli_query
(
$this
->
conn
(),
"INSERT INTO `data_user` VALUES (NULL, '
$ID
', '
$nama
', '
$notset
', '
$notset
', '
$ab
', '
$angkatan
', '
$prodi
', '
$ok
')"
)){
$this
->
sessStart
();
$_SESSION
[
'login'
]
=
TRUE
;
$_SESSION
[
'id'
]
=
$ID
;
header
(
'Location: index.php'
);
}
else
{
echo
"ga bisa"
;
header
(
'Location: register.php'
)
;
}
}
}
...
...
@@ -248,5 +271,99 @@
$data
=
mysqli_fetch_assoc
(
$result
);
return
$data
[
'total'
];
}
function
jk1
(
$int
,
$name
){
$check
=
$this
->
conn
()
->
query
(
"SELECT * from data_user where id_nama='
$int
'"
);
if
(
$check
){
$d
=
mysqli_fetch_array
(
$check
);
if
(
!
empty
(
$d
[
$name
])){
$idmarga
=
$d
[
$name
];
$check2
=
$this
->
conn
()
->
query
(
"SELECT jk from Jenis_kelamin where id='
$idmarga
'"
);
if
(
$check2
){
$f
=
mysqli_fetch_array
(
$check2
);
if
(
$f
[
'jk'
]
==
'L'
){
return
'1'
;
}
else
{
return
'2'
;
}
}
}
}
}
function
profile12
(
$int
,
$name
){
$check
=
$this
->
conn
()
->
query
(
"SELECT * from data_user where id_nama='
$int
'"
);
if
(
$check
){
$d
=
mysqli_fetch_array
(
$check
);
if
(
!
empty
(
$d
[
$name
])){
return
$d
[
$name
];
}
else
{
return
"0"
;
}
}
}
function
marga1
(
$int
,
$name
){
$check
=
$this
->
conn
()
->
query
(
"SELECT * from data_user where id_nama='
$int
'"
);
if
(
$check
){
$d
=
mysqli_fetch_array
(
$check
);
if
(
!
empty
(
$d
[
$name
])){
return
$d
[
$name
];
}
else
{
return
8
;
}
}
}
function
marga112
(
$name
){
$check
=
$this
->
conn
()
->
query
(
"SELECT * from marga where marga like '
$name
'"
);
if
(
$check
){
$d
=
mysqli_fetch_array
(
$check
);
return
$d
[
'id_marga'
];
}
}
}
//-------------------------
class
SudahLogin
{
var
$host
=
"localhost"
;
var
$uname
=
"root"
;
var
$pass
=
""
;
var
$db
=
"pabi"
;
function
conn
(){
$conn
=
mysqli_connect
(
$this
->
host
,
$this
->
uname
,
$this
->
pass
,
$this
->
db
);
return
$conn
;
}
function
EditDataProfile
(
$nama
,
$marga
,
$beibe
,
$kelamin
,
$prodi
,
$angkatan
,
$id
,
$kelas
){
$result
=
mysqli_query
(
$this
->
conn
(),
"Select * from data_user where id_user = '
$id
'"
);
$data
=
mysqli_fetch_array
(
$result
);
$test1
=
new
data
();
$test
=
new
data
();
if
(
empty
(
$nama
))
$nama
=
$test1
->
profile
(
$id
,
'nama'
);
else
$nama
=
$nama
;
if
(
empty
(
$marga
))
$marga
=
$test1
->
marga1
(
$id
,
'marga'
);
else
$marga
=
$test
->
marga112
(
$marga
);
if
(
empty
(
$beibe
))
$beibe
=
$test1
->
marga1
(
$id
,
'mamak'
);
else
$beibe
=
$test
->
marga112
(
$beibe
);
if
(
empty
(
$kelamin
))
$kelamin
=
$test1
->
jk1
(
$id
,
'marga'
);
else
$kelamin
=
$kelamin
;
if
(
empty
(
$prodi
))
$prodi
=
$test1
->
profile
(
$id
,
'prodi'
);
else
$prodi
=
$prodi
;
if
(
empty
(
$angkatan
))
$angkatan
=
$test1
->
profile12
(
$id
,
'angkatan'
);
else
$angkatan
=
$angkatan
;
if
(
empty
(
$kelas
))
$kelas
=
$test1
->
profile
(
$id
,
'kelas'
);
else
$kelas
=
$kelas
;
$this
->
userUpdate
(
$nama
,
$marga
,
$beibe
,
$kelamin
,
$prodi
,
$angkatan
,
$id
,
$kelas
);
// header('Location: ias.php?marga='.$marga.'&beibe='.$beibe);
}
function
userUpdate
(
$nama
,
$marga
,
$beibe
,
$kelamin
,
$prodi
,
$angkatan
,
$id
,
$kelas
){
$sql
=
"UPDATE data_user SET nama = '
$nama
', marga = '
$marga
' , mamak = '
$beibe
' , kelas = '
$kelas
' , angkatan = '
$angkatan
' , prodi = '
$prodi
', Jenis_kelamin = '
$kelamin
' WHERE id_nama = '
$id
'"
;
$ok
=
$this
->
conn
();
if
(
mysqli_query
(
$ok
,
$sql
))
{
echo
"Record updated successfully"
;
}
else
{
echo
"Error updating record: "
.
mysqli_error
(
$ok
);
}
header
(
'Location: profile.php?'
);
}
}
?>
profile.php
View file @
2f43bf4a
...
...
@@ -88,6 +88,11 @@
<td><h3>
<?php
$d
=
$ok
->
jk
(
$temp
,
'Jenis_kelamin'
);
echo
$d
;
?>
</h3></td>
</tr>
<tr>
<td><h3>
Kelas
</h3></td>
<td><h3>
:
</h3></td>
<td><h3>
<?php
$d
=
$ok
->
profile
(
$temp
,
'kelas'
);
echo
$d
;
?>
</h3></td>
</tr>
<tr>
<td><h3>
Prodi
</h3></td>
<td><h3>
:
</h3></td>
<td><h3>
<?php
$d
=
$ok
->
profile
(
$temp
,
'prodi'
);
echo
$d
;
?>
</h3></td>
...
...
register.php
View file @
2f43bf4a
...
...
@@ -2,8 +2,11 @@
include_once
'fungsi.php'
;
$o
=
new
data
();
$o
->
sessStart
();
if
(
isset
(
$_
))
{
// code...
if
(
isset
(
$_GET
[
'alert'
]))
{
echo
"<script>alert('Username Sudah digunakan, harap coba yang lain');window.location='register.php'</script>"
;
}
if
(
isset
(
$_SESSION
[
'login'
])){
header
(
'Location: index.php'
);
}
?>
...
...
test.php
View file @
2f43bf4a
...
...
@@ -2,5 +2,5 @@
include_once
'fungsi.php'
;
$db
=
new
data
();
if
(
isset
(
$_GET
[
'username'
]))
$db
->
register
(
$_GET
[
'username'
],
$_GET
[
'pass'
],
$_GET
[
'gender'
]);
$db
->
Test
register
(
$_GET
[
'username'
],
$_GET
[
'pass'
],
$_GET
[
'gender'
]);
?>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment