How to show student_id from the database by using email and password and then link it to new page

I was trying to connect my login.php page with a new blog.php page using phpmyadmin and xamp server.
I use email and password to login into the account and once the input are correct the page should redirect to another blog.php page.
Also in my blog.php page i want to print the student_id and name from the database.
this is my login.php

<?php include("server.php") ?> <?php if(isset($_POST['login_now'])) { $email = mysqli_real_escape_string($db, $_POST['email']); $Password = mysqli_real_escape_string($db, $_POST['password']); $query = "SELECT * FROM register WHERE email='$email' AND Password ='$Password'"; $results = mysqli_query($db, $query); $sql = "SELECT student_id, name FROM register WHERE email='$email' AND Password ='$Password'"; $result = $db->query($sql); if ($result->num_rows > 0) { // output data of each row while($row = $result->fetch_assoc()) { echo "student_id: " . $row["student_id"]. " - Name: " . $row["name"]. " " . "
"; if (isset($_SESSION["student_id"])) { header("Location: blog.php"); } } } } ?> Registration System

Login Now

<p>   NOT MEMBER? <a href="register.php"> SIGN UP </a>

this is my blog.php under maintenance

<?php session_start(); echo "hello"; echo $_SESSION["student_id"]; ?>
<!DOCTYPE html>
Registration System


Also this is my server.php that i have included in my login.php

<?php session_start(); $name = ""; $email = ""; $password_1 =""; $phone_number =""; $servername = "localhost"; $username = "root"; $Password = ""; $dbname = "satyam"; $db = new mysqli($servername, $username, $Password, $dbname ); if (mysqli_connect_errno()) { echo "Failed to connect to MySQL: " . mysqli_connect_error(); } echo "connected succesfully"; ?>

I know the code is not best I apologize, I have just started coding and it’s all very confusing sometimes.

I’m sorry but this forum is for 000webhost issues and not coding issues.