Postingan lainnya
Gagal membuat update password baru (error password lama tidak terbaca pada perintah query)
<?php
$id = @$_GET['id_user'];
$query = mysqli_query($koneksi,"SELECT * FROM tbl_user WHERE id_user = '$id'") or die (mysqli_error($koneksi));
$data = mysqli_fetch_array($query);
?>
<?php
//Proses ganti Password
if(@$_POST['edit']){
$id_user = @$_POST['id_user'];
$username = @$_POST['username'];
$password_lama = @$_POST['password_lama'];
$password_baru = @$_POST['password_baru'];
$conf_password = @$_POST['conf_password'];
$sumber = @$_FILES['photo']['tmp_name'];
$target = '../image/';
$ukuran_file = $_FILES['photo']['size'];
$tipe_file = $_FILES['photo']['type'];
$photo = @$_FILES['photo']['name'];
//Cek Password lama
$query = mysqli_query($koneksi,"SELECT * FROM tbl_user WHERE username = '$username' AND password = md5('$password_lama')");
$hasil = mysqli_num_rows($query);
var_dump($hasil);
if (! $hasil >= 1) {
?>
<script language="JavaScript">alert('Password lama tidak sesuai!, silahkan ulang kembali!'); document.location='dashboard.php';
</script>
<?php
}
Tanggapan
halo, biasakan diperjelas, tidak bisanya dimana, errornya apa, yang diharapkan apa
errornya di verifikasi password lama sama dengan data password di database
coba ditambahkan di atas keterangannya, baca "aturan main" cara bertanya yang baik, jangan hanya paste kodenya
4 Jawaban:
coba pakai
<pre> if($hasil < 1 ) { // password lama tidak sesuai } </pre>
Tanggapan
Masih belum solved
<pre>
//Proses ganti Password
if(@$_POST['edit']){
$id_user = @$_POST['id_user'];
$username = @$_POST['username'];
$password_lama = @$_POST['password_lama'];
$password_baru = @$_POST['password_baru'];
$conf_password = @$_POST['conf_password'];
$sumber = @$_FILES['photo']['tmp_name'];
$target = '../image/';
$ukuran_file = $_FILES['photo']['size'];
$tipe_file = $_FILES['photo']['type'];
$photo = @$_FILES['photo']['name'];
//Cek Password lama
$password_lama = md5('password_lama');
$query = mysqli_query($koneksi,"SELECT * FROM tbl_user WHERE id_user = '$id_user' AND password = '$password_lama'") or die (mysqli_error($koneksi));
$count = mysqli_num_rows($query);
var_dump($count);
if($photo == ""){
if($count &lt; 1){
if(strlen($password_baru) &gt;= 5){
if($password_baru == $conf_password){
$password_baru = md5($password_baru);
@$id_user = $_SESSION['id_user'];
$update = mysqli_query($koneksi,"UPDATE tbl_user SET password = '$password_baru' WHERE id_user = '$id_user'");
if($update){
?&gt;
&lt;script type="text/javascript"&gt;alert("Password Berhasil di Ubah");
window.location.href="dashboard.php";&lt;/script&gt;
&lt;?php
}else{
?&gt;
&lt;div class="alert alert-danger alert-dismissible" role="alert"&gt;
Gagal Ubah Password
&lt;button type="button" class="close" data-dismiss="alert" aria-label="Close"&gt;
&lt;span aria-hidden="true"&gt;&times;&lt;/span&gt;
&lt;/button&gt;
&lt;/div&gt;
&lt;?php
}
}else{
?&gt;
&lt;div class="alert alert-danger alert-dismissible" role="alert"&gt;
Konfirmasi password tidak cocok
&lt;button type="button" class="close" data-dismiss="alert" aria-label="Close"&gt;
&lt;span aria-hidden="true"&gt;&times;&lt;/span&gt;
&lt;/button&gt;
&lt;/div&gt;
&lt;?php
}
}else{
?&gt;
&lt;div class="alert alert-danger alert-dismissible" role="alert"&gt;
Minimal Password baru adalah 5 karakter
&lt;button type="button" class="close" data-dismiss="alert" aria-label="Close"&gt;
&lt;span aria-hidden="true"&gt;&times;&lt;/span&gt;
&lt;/button&gt;
&lt;/div&gt;
&lt;?php
}
}else{
?&gt;
&lt;div class="alert alert-danger alert-dismissible" role="alert"&gt;
Password Lama Tidak Sesuai
&lt;button type="button" class="close" data-dismiss="alert" aria-label="Close"&gt;
&lt;span aria-hidden="true"&gt;&times;&lt;/span&gt;
&lt;/button&gt;
&lt;/div&gt;
&lt;?php
}
</pre>
Udah berusaha tapi masih belum solved juga
Kamu ubah kondisi if di bagian ini <pre> if($count < 1){} //jadi if($count > 0){ //your code here } </pre>
coba di echo querynya, jalankan manual. berhasil atau tidak