ini syntaxnya . .

<?
session_start();
include_once("db_config.php");
#jika ditekan tombol login
if(isset($_POST)) {
$username = $_POST;
$password = $_POST;
$sql = mysql_query("SELECT * FROM admin WHERE username='$username' &&
password='$password'");
$num = mysql_num_rows($sql);
if($num==1) {
// login benar //
$_SESSION = $username;
$_SESSION = $password;
?><script language="JavaScript">alert('Anda berhasil login');
document.location='select_semua.php'</script><?
} else {
// jika login salah //
?><script language="JavaScript">alert('Username atau password Anda
salah'); document.location='login.php'</script><?
}
}

?>

ini form login nya
</head>
<body>
<div align="center">
<form action="periksa.php" method="post" name="login">
<table width="286" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr bgcolor="#FF6633">
<td height="19" colspan="2" align="center" valign="middle">
<font color="#FFFFFF">ADMIN</font></td>
</tr>
<tr>
<td width="106" height="27">&nbsp;</td>
<td width="180">&nbsp;</td>
</tr>
<tr>
<td height="18" align="right" valign="middle">Username :&nbsp;</td>
<td valign="middle">
<input name="username" type="text" id="username" size="20"></td>
</tr>
<tr>
<td height="18" align="right" valign="middle">Password :&nbsp;</td>
<td valign="middle">
<input name="password" type="password" id="password" size="20"></td>
</tr>
<tr>
<td height="19">&nbsp;</td>
<td></td>
</tr>
<tr>
<td height="18" valign="top"><!--DWLayoutEmptyCell-->&nbsp;</td>
<td valign="middle">
<input name="login" type="submit" id="login" value=" Login "></td>
</tr>
<tr>
<td height="28">&nbsp;</td>
<td></td>
</tr>
<tr bgcolor="#FF6633">
<td height="18" colspan="2" valign="top"><!--DWLayoutEmptyCell-->&nbsp;</td>
</tr>
</table>
</form>
</div>
</body>
</html>
Silahkan login untuk menjawab!
1
Loading...
Ellyx Christian · Jun 29, 2011 · 1 Suka · 0 Tidak Suka
pada saat login alert message yang mana muncul? "Username atau password Anda
salah" apa "Anda berhasil login"?
coba ikuti tutorial ini: http://www.myphptutorials.com/tutorials/12/forum-user-login-log-out-system
0
Loading...
Just Faldi · Jun 29, 2011 · 0 Suka · 0 Tidak Suka
anda berhasil login . . gitu terus walau salah user ma pass nya . .
0
Loading...
Ellyx Christian · Jun 29, 2011 · 0 Suka · 0 Tidak Suka
coba setelah
$sql = mysql_query("SELECT * FROM admin WHERE username='$username' &&
password='$password'");
tambahkan:
echo '<pre>';
echo var_export(mysql_fetch_array($sql), true);
echo '</pre>';
exit;

dan lihat apa yang muncul?
0
Loading...
Just Faldi · Jun 29, 2011 · 0 Suka · 0 Tidak Suka
malah keluar ini
echo '<pre>';
echo var_export(mysql_fetch_array($sql), true);
echo '</pre>';
exit;

itu syntax dibawah nya udah dihapus . . ato tetep ditampilkan yang
$_SESSION = $username;
$_SESSION = $password;
?><script language="JavaScript">alert('Anda berhasil login');
document.location='select_semua.php'</script><?
0
Loading...
Ellyx Christian · Jun 29, 2011 · 0 Suka · 0 Tidak Suka
coba ubah kode kamu manjadi seperti ini:
<?php
session_start();
include_once("db_config.php");
#jika ditekan tombol login
if(isset($_POST['login'])) {
$username = $_POST['username'];
$password = $_POST['password'];
$sql = mysql_query("SELECT * FROM admin WHERE username='$username' &&
password='$password'");
echo '<pre>';
echo var_export(mysql_fetch_array($sql), true);
echo '</pre>';
exit;
$num = mysql_num_rows($sql);
if($num==1) {
// login benar //
$_SESSION['user'] = $username;
$_SESSION['password'] = $password;
?><script language="JavaScript">alert('Anda berhasil login');
document.location='select_semua.php'</script><?
} else {
// jika login salah //
?><script language="JavaScript">alert('Username atau password Anda
salah'); document.location='login.php'</script><?
}
}

?>
coba lihat hasilnya
0
Loading...
Just Faldi · Jun 29, 2011 · 0 Suka · 0 Tidak Suka
gan ellyx . . saya pake coba ikuti tutorial ini: http://www.myphptutorials.com/tutorials/12/forum-user-login-log-out-system .

lebih mudah dimengerti . .
yang diatas salah mulu . . .

terimakasih banyak . .
0
Loading...
Ellyx Christian · Jun 29, 2011 · 0 Suka · 0 Tidak Suka
ok no problem
0
Loading...
Just Faldi · Jun 29, 2011 · 0 Suka · 0 Tidak Suka
oh iya gan . . maaf OOT . . 1 pertanyaan lagi . .
kalo ini kesalahannya dimana ya ??
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''1' at line 14

ini syntax nya . .
<?php
include_once 'db_config.php';

if(isset($_POST))
{
$c_id=$_POST;
$tgl_in=$_POST;
$tgl_out=$_POST;
$jenis_kamar=$_POST;
$nama=$_POST;
$no_ktp=$_POST;
$address=$_POST;
$company=$_POST;
$mobile_phone=$_POST;
$office_phone=$_POST;
$e_mail=$_POST;
$city=$_POST;
$country=$_POST;
$post_code=$_POST;

$sql= "update user set
tgl_in='".$tgl_in."',
tgl_out='".$tgl_out."',
jenis_kamar='".$jenis_kamar."',
nama='".$nama."',
no_ktp='".$address."',
company='".$company."',
mobile_phone='".$mobile_phone."',
office_phone='".$office_phone."',
e_mail='".$e_mail."',
city='".$city."',
country='".$country."',
post_code='".$post_code."'
where id_user='".$c_id;

$query=mysql_query($sql)or die(mysql_error());

echo("Data berhasil di update");
echo("<br><br>");
echo("<a href='select_semua.php'>Kembali Ke Daftar</a>");
}
?>

ini lagi bikin form edit . .
0
Loading...
Ellyx Christian · Jun 29, 2011 · 0 Suka · 0 Tidak Suka
itu karena sql yang kamu bentuk salah, coba sebelum $query=mysql_query($sql)or die(mysql_error()); tambahkan echo $sql; biar tahu sql yang terbentuk dan dimana kesalahannya.
0
Loading...
Just Faldi · Jun 29, 2011 · 0 Suka · 0 Tidak Suka
keluar ini
update user set tgl_in='2011-06-07', tgl_out='', jenis_kamar='', nama='faldi', no_ktp='jln. gagak 151', company='none', mobile_phone='222509183', office_phone='2147483647', e_mail='faldi_stockholm@yaho', city='bandung', country='indonesia', post_code='44115' where id_user='1You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''1' at line 14