the code for login.
<?php
$database="umj";
$hostname="localhost";
$username="mysql";
$password="localhost";
$db=mysql_connect($hostname,$username,$password) or die ("cannot connected");
mysql_select_db($database,$db);
$sql="select no_bp,nama_mhs,pin from mhs where no_bp='$no_bp' and pin='$pin'";
if(!$result=mysql_query($sql,$db));
{
echo mysql_error();
}
if($no_bp !="" and $pin != "")
{
setcookie("no_bp",$no_bp);
setcookie("pin",$pin);
header("location:welcome.php");
}
else
{
header("location:utama.html");
exit();
}
?>
at the page welcome.php I wrote
<?php echo "welcome $no_bp" ?>
it seems to me it doesn't recognise the ccokie cause it said invalid variable no_bp,
also, no matter i enter the right/wrong password. it direct me to welcome.php .
please tell me what's wrong with that simple code cause cookie really confusing me.
<?php
$database="umj";
$hostname="localhost";
$username="mysql";
$password="localhost";
$db=mysql_connect($hostname,$username,$password) or die ("cannot connected");
mysql_select_db($database,$db);
$sql="select no_bp,nama_mhs,pin from mhs where no_bp='$no_bp' and pin='$pin'";
if(!$result=mysql_query($sql,$db));
{
echo mysql_error();
}
if($no_bp !="" and $pin != "")
{
setcookie("no_bp",$no_bp);
setcookie("pin",$pin);
header("location:welcome.php");
}
else
{
header("location:utama.html");
exit();
}
?>
at the page welcome.php I wrote
<?php echo "welcome $no_bp" ?>
it seems to me it doesn't recognise the ccokie cause it said invalid variable no_bp,
also, no matter i enter the right/wrong password. it direct me to welcome.php .
please tell me what's wrong with that simple code cause cookie really confusing me.