₦airaland Forum

Welcome, Guest: RegisterLoginWith GoogleTrendingRecentNew

Stats: 3,327,371 members, 8,430,705 topics. Date: Saturday, 20 June 2026 at 10:45 PM

Toggle theme

Emmysuit's Posts

Nairaland ForumEmmysuit's ProfileEmmysuit's Posts

1 (of 1 pages)

ProgrammingLogin Username From One Table And Password From Table 2 by Emmysuit(op): 10:27am On Jul 07, 2017
please i need help to with the code of the one below. am trying to create a login page the select username from one table and select password from another table but am confused now please help me with correct code of the on below



<?
include("connect.php"wink;
$tbl_name1="student"; // Table name
$tbl_name2="pin_generate"; // Table name

$registration_number=$_POST['registration_number']; // username sent from form
$pin=$_POST['pin']; // pin sent from form


// To protect MySQL injection
$registration_number = stripslashes($registration_number);
$pin = stripslashes($pin);
$registration_number = mysql_real_escape_string($registration_number);
$pin = mysql_real_escape_string($pin);

//Query
$sql="SELECT registration_number pin FROM $tbl_name1, $tbl_name2 WHERE registration_number='$registration_number' and pin='$pin'";
$result=mysql_query($sql);
// Mysql_num_row is counting table row


while ($row = mysql_fetch_assoc($result)) {
if ($row['count'] == '0') {
header('location: user1.html'); //User1
session_register("registration_number"wink;
session_register("pin"wink;

}
else
if ($row['count'] == '1') {
header('location: user2.html'); //User2
$_SESSION['login_user'] = $registration_number;
session_register("registration_number"wink;
session_register("pin"wink;
echo "<script>alert('Access Denied!');
.location='index.php';
</script>";
}
}


//Direct pages with different user levels


?>

1 (of 1 pages)