Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

PHP

My Webpage is not loading when i use the session..

hears my code

<?php $pageTitle="create feedback page"; include ("inc/header.php");

 ?>

<?php session_start(); $_SESSION["name"] = $_POST['user_rollno']; $_SESSION["password"]=$_POST['user_password']; include ('inc/db_connection.php'); try{ $results = $db->prepare("SELECT * FROM teacher WHERE name = :name AND password = :password "); $results->bindParam(':name',$_SESSION["name"], PDO::PARAM_STR ); $results->bindParam(':password',$_SESSION["password"], PDO::PARAM_STR) ; $results->execute(); } catch (Exception $ex) { echo 'Data Can Not Be retrived'; include ("inc/footer.php"); exit(); } $validater = $results->fetch(PDO::FETCH_ASSOC); if($validater==0){ echo 'Password Or ID Is Incorrect'; include ("inc/footer.php"); exit(); } include ("inc/createform.php"); ?> <?php include ("inc/footer.php"); ?>

1 Answer

It looks like you closed your PHP tags before you started the session, so try opening a PHP tag before your session_start();. Also, it looks like you need to open another PHP tag before your footer include statement, as well.

Also, try starting your session as the very first line of code and then putting all of its related parameters beneath your include files that you have at the top of your current code.

Other than that, your syntax doesn't shout anything that would produce a fatal error.

I hope it's something small like that!

ws the server error... nywys tysm