I have spent lot of time on this, but still what i got is " undefined variable :no_bp , undefined variable in.
seem that i can't create cookies into my page. i have also tried session register, and but i got is the same.
could you help me please, what's wrong with my codes?there are 3 files.
loginumj.html
<body>
<form action="loginumj.php" method="post">
no bp :<input type=text name=no_bp><br>
pin :<input type=password name="pin"><br>
<input type=submit name=submit value-"login">
</form>
</body>
loginumj.php
<?php
setcookie("no_bp",$no_bp);
setcookie("pin",$pin);
$database="campus";
$hostname="localhost";
$username="hilma76";
$password="purusbaru";
$db=mysql_connect($hostname,$username,$password) or die ("cannot connected");
mysql_select_db($database);
$statement="select no_bp,pin,nama_mhs from mahasiswa where no_bp='$no_bp' and pin='$pin'";
if(!$result=mysql_db_query($database,$statement))
{
echo "query error()";
exit();
}
$num_rows=mysql_num_rows($result);
if($num_rows)
{
setcookie("no_bp",$no_bp);
setcookie("pin",$pin);
header("location:welcome.php");
exit();
}
else
{
echo "gagal";
exit();
}
?>
welcome.php
<?php
$hostname="localhost";
$username="hilma76";
$password="purusbaru";
$database="campus";
$db=mysql_connect($hostname,$username,$password) or die ("cannot connected");
mysql_select_db($database);
$statement="select nama_mhs from mahasiswa where no_bp='$no_bp' and pin='$pin' ";
if(!$result=mysql_db_query($database,$statement))
{
echo "query error";
exit();
}
while ($row=mysql_fetch_row($result))
{
echo $row[0];
}
?>
<head>
<title>Binus Training Homepage</title>
</head>
<body>
<h1>selamat datang <?php echo $row[0] ?>
</body>
Thanks for your help.
seem that i can't create cookies into my page. i have also tried session register, and but i got is the same.
could you help me please, what's wrong with my codes?there are 3 files.
loginumj.html
<body>
<form action="loginumj.php" method="post">
no bp :<input type=text name=no_bp><br>
pin :<input type=password name="pin"><br>
<input type=submit name=submit value-"login">
</form>
</body>
loginumj.php
<?php
setcookie("no_bp",$no_bp);
setcookie("pin",$pin);
$database="campus";
$hostname="localhost";
$username="hilma76";
$password="purusbaru";
$db=mysql_connect($hostname,$username,$password) or die ("cannot connected");
mysql_select_db($database);
$statement="select no_bp,pin,nama_mhs from mahasiswa where no_bp='$no_bp' and pin='$pin'";
if(!$result=mysql_db_query($database,$statement))
{
echo "query error()";
exit();
}
$num_rows=mysql_num_rows($result);
if($num_rows)
{
setcookie("no_bp",$no_bp);
setcookie("pin",$pin);
header("location:welcome.php");
exit();
}
else
{
echo "gagal";
exit();
}
?>
welcome.php
<?php
$hostname="localhost";
$username="hilma76";
$password="purusbaru";
$database="campus";
$db=mysql_connect($hostname,$username,$password) or die ("cannot connected");
mysql_select_db($database);
$statement="select nama_mhs from mahasiswa where no_bp='$no_bp' and pin='$pin' ";
if(!$result=mysql_db_query($database,$statement))
{
echo "query error";
exit();
}
while ($row=mysql_fetch_row($result))
{
echo $row[0];
}
?>
<head>
<title>Binus Training Homepage</title>
</head>
<body>
<h1>selamat datang <?php echo $row[0] ?>
</body>
Thanks for your help.