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
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
202 additions
and
70 deletions
+202
-70
edit_profile.php
edit_profile.php
+69
-62
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
'
]);
}
?>
...
...
@@ -68,67 +69,73 @@
<section
class=
"service-section spad"
>
<div
class=
"container"
>
<form
class=
""
action=
"edit_profile.php"
method=
"post"
>
<table
class=
"w3-table w3-striped"
>
<tr>
<td><h3>
Nama
</h3></td>
<td><h3>
:
</h3></td>
<td><h3>
<input
class=
"w3-input w3-border"
name=
"nama"
type=
"text"
placeholder=
"
<?php
$d
=
$ok
->
Editprofile
(
$temp
,
'nama'
);
echo
$d
;
?>
"
></h3></td>
</tr>
<tr>
<td><h3>
Marga
</h3></td>
<td><h3>
:
</h3></td>
<td><h3>
<select
id=
"marga"
name=
"marga"
style=
"width: 100%"
>
<option
></option>
<?php
$result
=
mysqli_query
(
$ok
->
conn
(),
'Select * from marga'
);
while
(
$user_data
=
mysqli_fetch_array
(
$result
)){
?>
<option
value=
"
<?php
echo
$user_data
[
'marga'
];
?>
"
>
<?php
echo
$user_data
[
'marga'
];
?>
</option>
<?php
}
?>
</select>
</h3></td>
</tr>
<td><h3>
Beibe
</h3></td>
<td><h3>
:
</h3></td>
<td><h3>
<select
id=
"beibe"
name=
"beibe"
style=
"width: 100%"
>
<option
></option>
<?php
$result
=
mysqli_query
(
$ok
->
conn
(),
'Select * from marga'
);
while
(
$user_data
=
mysqli_fetch_array
(
$result
)){
?>
<option
value=
"
<?php
echo
$user_data
[
'marga'
];
?>
"
>
<?php
echo
$user_data
[
'marga'
];
?>
</option>
<?php
}
?>
</select>
</h3></td>
</tr>
</tr>
<td><h3>
Jenis Kelamin
</h3></td>
<td><h3>
:
</h3></td>
<td><h3>
<select
id=
"Jenis_kelamin"
name=
"Jenis_kelamin"
style=
"width: 100%"
>
<option
></option>
<option
value=
"1"
>
Laki - Laki
</option>
<option
value=
"2"
>
Perempuan
</option>
</select>
</h3></td>
</tr>
<tr>
<td><h3>
Prodi
</h3></td>
<td><h3>
:
</h3></td>
<td><h3>
<input
class=
"w3-input w3-border"
name=
"prodi"
type=
"text"
placeholder=
"
<?php
$d
=
$ok
->
Editprofile
(
$temp
,
'prodi'
);
echo
$d
;
?>
"
></h3></td>
</tr>
<tr>
<td><h3>
Angkatan
</h3></td>
<td><h3>
:
</h3></td>
<td><h3>
<input
class=
"w3-input w3-border"
name=
"angkatan"
type=
"text"
placeholder=
"
<?php
$d
=
$ok
->
Editprofile
(
$temp
,
'angkatan'
);
echo
$d
;
?>
"
></h3></td>
</tr>
<tr>
<td>
<input
type=
"hidden"
name=
"id"
value=
"
<?php
echo
$temp
?>
"
>
</td>
<td></td>
<td>
<input
type=
"submit"
name=
"SubmitEditProfile"
value=
"Submit"
>
</td>
</tr>
</table>
</form>
<table
class=
"w3-table w3-striped"
>
<tr>
<td><h3>
Nama
</h3></td>
<td><h3>
:
</h3></td>
<td><h3>
<input
class=
"w3-input w3-border"
name=
"nama"
type=
"text"
placeholder=
"
<?php
$d
=
$ok
->
Editprofile
(
$temp
,
'nama'
);
echo
$d
;
?>
"
></h3></td>
</tr>
<tr>
<td><h3>
Marga
</h3></td>
<td><h3>
:
</h3></td>
<td><h3>
<select
id=
"marga"
name=
"marga"
style=
"width: 100%"
>
<option
></option>
<?php
$result
=
mysqli_query
(
$ok
->
conn
(),
'Select * from marga'
);
while
(
$user_data
=
mysqli_fetch_array
(
$result
)){
?>
<option
value=
"
<?php
echo
$user_data
[
'marga'
];
?>
"
>
<?php
echo
$user_data
[
'marga'
];
?>
</option>
<?php
}
?>
</select>
</h3></td>
</tr>
<td><h3>
Beibe
</h3></td>
<td><h3>
:
</h3></td>
<td><h3>
<select
id=
"beibe"
name=
"beibe"
style=
"width: 100%"
>
<option
></option>
<?php
$result
=
mysqli_query
(
$ok
->
conn
(),
'Select * from marga'
);
while
(
$user_data
=
mysqli_fetch_array
(
$result
)){
?>
<option
value=
"
<?php
echo
$user_data
[
'marga'
];
?>
"
>
<?php
echo
$user_data
[
'marga'
];
?>
</option>
<?php
}
?>
</select>
</h3></td>
</tr>
</tr>
<td><h3>
Jenis Kelamin
</h3></td>
<td><h3>
:
</h3></td>
<td><h3>
<select
id=
"Jenis_kelamin"
name=
"Jenis_kelamin"
style=
"width: 100%"
>
<option
></option>
<option
value=
"1"
>
Laki - Laki
</option>
<option
value=
"2"
>
Perempuan
</option>
</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>
<td><h3>
<input
class=
"w3-input w3-border"
name=
"prodi"
type=
"text"
placeholder=
"
<?php
$d
=
$ok
->
Editprofile
(
$temp
,
'prodi'
);
echo
$d
;
?>
"
></h3></td>
</tr>
<tr>
<td><h3>
Angkatan
</h3></td>
<td><h3>
:
</h3></td>
<td><h3>
<input
class=
"w3-input w3-border"
name=
"angkatan"
type=
"text"
placeholder=
"
<?php
$d
=
$ok
->
Editprofile
(
$temp
,
'angkatan'
);
echo
$d
;
?>
"
></h3></td>
</tr>
<tr>
<td>
<input
type=
"hidden"
name=
"id"
value=
"
<?php
echo
$temp
?>
"
>
</td>
<td></td>
<td>
<input
type=
"submit"
name=
"SubmitEditProfile"
value=
"Submit"
>
</td>
</tr>
</table>
</form>
</div>
</section>
...
...
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