Function mysql_real_escape_string error

Fatal error: Uncaught Error: Call to undefined function mysql_real_escape_string() in D:\XAMPP\xampp\htdocs\alfalah\sim\action\LoginAction.php:9 Stack trace: #0 D:\XAMPP\xampp\htdocs\alfalah\sim\action\LoginAction.php(54): getLogin('asep', '1234') #1 {main} thrown in D:\XAMPP\xampp\htdocs\alfalah\sim\action\LoginAction.php on line 9

avatar ahmadrivai
@ahmadrivai

23 Kontribusi 0 Poin

Dipost 5 tahun yang lalu

Tanggapan

coba upload kode sebagai kode gan, bukan sebagai gambar, baca aturan main, cara bertanya yang baik dan jelas

diedit mas rivai pertanyannya, jangan ditaro di jawaban

Kodingnya ditaruh di dlam tag code gan, klik tanda kurung kotak, paste kodenya disna

1 Jawaban:

<pre> &lt;?php session_start(); include_once '../db/DBConnection.php'; include_once '../model/Personal.php'; include_once '../model/User.php'; include_once '../library/Enkripsi.php'; $error=0; function getLogin($username,$password){ $user= mysql_real_escape_string($username,DBConnection::getConnection());//strip_tags($username); //untuk mencegah sql injektion $pwd= mysql_real_escape_string($password,DBConnection::getConnection());//strip_tags($password); //untuk encegah sql injektion $user=NULL; $sql="select * from user where username='$usr' and password='".encrypt_decrypt('encrypt', $pwd)."'"; $dataQry = mysql_query($sql, DBConnection::getConnection())or die("Query error :". mysql_error()); while ($dataRow= mysql_fetch_array($dataQry)){
$user=new User(); $user-&gt;setUserId($dataRow['id_user']); $user-&gt;setUsername($dataRow['username']); $user-&gt;setPassword($dataRow['password']); $user-&gt;setLevel($dataRow['level']); $user-&gt;setPersonalId($dataRow['personal_id']); $user-&gt;setPertanyaan($dataRow['pertanyaan']); $user-&gt;setJawaban($dataRow['jawaban']); $user-&gt;setPersonal(getPersonal($dataRow['personal_id'])); } return $user; }

function getPersonal($id){ $personal=NULL; $sql="select * from personal where id_siswa='$id'"; $dataQry = mysql_query($sql, DBConnection::getConnection())or die("Query error :". mysql_error()); while ($dataRow= mysql_fetch_array($dataQry)){
$personal=new Personal(); $personal-&gt;setIdPersonal($dataRow['id_siswa']); $personal-&gt;setNamaAwal($dataRow['nama_awal']); $personal-&gt;setNamaTengah($dataRow['nama_tengah']); $personal-&gt;setNamaAkhir($dataRow['nama_akhir']); $personal-&gt;setTempatLahir($dataRow['tempat_lahir']); $personal-&gt;setTglLahir($dataRow['tgl_lahir']); $personal-&gt;setTelepon($dataRow['telepon']); $personal-&gt;setAlamat($dataRow['alamat']); $personal-&gt;setKota($dataRow['kota']); $personal-&gt;setPropinsi($dataRow['propinsi']); $personal-&gt;setNegara($dataRow['negara']); $personal-&gt;setEmail($dataRow['email']); $personal-&gt;setKelamin($dataRow['kelamin']); $personal-&gt;setKategoriSantri($dataRow['kategori_santri']); $personal-&gt;setTglGabung($dataRow['tgl_gabung']); $personal-&gt;setFoto($dataRow['foto']); } return $personal; } if($_POST){ $loginPersonal =getLogin($_POST['txtUser'], $_POST['txtPassword']); if($loginPersonal==NULL){ echo "&lt;meta http-equiv='refresh' content='0; url=../'&gt;"; $error=1; }else{ /* @var $_SESSION type */ $_SESSION['SES_LOGIN'] = $loginPersonal-&gt;getPersonalId(); $_SESSION['SES_USER'] = $loginPersonal-&gt;getUsername(); $_SESSION['SES_NAMA']= $loginPersonal-&gt;getPersonal()-&gt;getNamaAwal()." ".$loginPersonal-&gt;getPersonal()-&gt;getNamaTengah()." ".$loginPersonal-&gt;getPersonal()-&gt;getNamaAkhir(); $_SESSION['SES_PERSONALID']=$loginPersonal-&gt;getPersonalId(); echo "&lt;meta http-equiv='refresh' content='0; url=../index.php'&gt;";

}

} ?&gt; &lt;script&gt; var pesan=&lt;?php echo $error; ?&gt;; if(pesan===1){ alert("Login Gagal Username Atau Password Tidak Valid !"); } &lt;/script&gt; </pre>

avatar ahmadrivai
@ahmadrivai

23 Kontribusi 0 Poin

Dipost 5 tahun yang lalu

Tanggapan

pertanyaan kamu gan yang diedit, bukan ditaro di "jawaban" orang nanti mengira ini jawaban. Klik tombol "edit pertanyaan" dan taru kode kamu diatas, salam

Login untuk ikut Jawaban