I made my first script of MySQLi. I have just learnt it from 3rd party website. So, I am not sure i am using functions which are not deprecated or outdated. I should start to practice good scripts to access databases. So, I have posted here. Any mistake you see, please point it out.
<?php
include "functions.php";
$a = checkLogin();
if($a==1) {
$id = $_COOKIE['id'];
include "databaseConnector.php";
$query = $mysqli->query("SELECT * FROM users WHERE id = '$id'") or die($mysqli->error.__LINE__);
if($query->num_rows > 0) {
while($row = $query->fetch_assoc()) {
?>
<?php echo stripslashes($row['firstname'])." ".stripslashes($row['lastname']); ?>
<?php
}
}
else {
return false;
}
}
else {
redirectIndex();
}
?>