versi 2

parent 5d66d3ab
......@@ -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>
......
......@@ -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?');
}
}
?>
......@@ -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>
......
......@@ -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');
}
?>
......
......@@ -2,5 +2,5 @@
include_once 'fungsi.php';
$db = new data();
if(isset($_GET['username']))
$db->register($_GET['username'],$_GET['pass'],$_GET['gender']);
$db->Testregister($_GET['username'],$_GET['pass'],$_GET['gender']);
?>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment