-1

I am building a school project a php /mysql script to show student marks i am done but am still having a problem in display page

Welcome.php

<?php
session_start();

if(!$_SESSION['email'])
{

    header("Location: login.php");//redirect to login page to secure the welcome page without login access.
}
$dbservername = "localhost";
$dbusername = "e351f301005e7788";
$dbpassword = "games123";
$dbname = "test";

// Create connection
$conn = new mysqli($dbservername, $dbusername, $dbpassword, $dbname);
// Check connection
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
}

$post_email = (!$_SESSION['email'])
$sql ="select * from student WHERE user_email='$post_email'";
$result = $conn->query($sql);

if ($result->num_rows > 0) {
    // output data of each row
        $row = $result->fetch_assoc();
        echo "username: " . $row['user_email'] . "<br>";
    }
} else {
    echo "Your Marks isn't ready yet";
}

$conn->close();
?> 

it keep displaying internal 500 error and i don't know the reason if any help will be apperciated Thanks for help !

1 Answers1

0
$post_email = (!$_SESSION['email'])

This line will give you a 500 error. Did you mean this?

$post_email = $_SESSION['email'];

Also in this section of your code you have more closing curly brackets than opening ones

if ($result->num_rows > 0) {
    // output data of each row
        $row = $result->fetch_assoc();
        echo "username: " . $row['user_email'] . "<br>";
    }
} else {
    echo "Your Marks isn't ready yet";
}
miknik
  • 5,748
  • 1
  • 10
  • 26