Headers Issue when invoking a Session...Maybe??

Hi,

I think this should be an easy one, but I can’t figure it out. When I try and invoke the page (see code below) I am not seeing any results except for the menu. I think it may have to do with headers being sent at the wrong time? Below is a snippet of the code that I hope will shed some light on what is going on, as well as the page source of the results.

If you could offer any help whatsoever, it would be greatly appreciated.

Code: [php]

<?php ob_start(); ?> Hockey Pool Headquarters <?php session_start(); include("header.inc.pbp"); include("db_connect.php"); $userid =& $_POST["userid"]; $password =& $_POST["password"]; if ($userid && $password) { // if the user has just tried to log in $db_conn = mysql_connect("$hostname", "$user", "$pass"); mysql_select_db("$database", $db_conn); $query = "select * from $authtable where name='$userid' and pass=md5('$password')"; $result = mysql_query($query, $db_conn) or die("Could not perform query: $query . " . mysql_error()); if (mysql_num_rows($result) > 0 ) { // if they are in the database register the user id session_register("valid_user"); $valid_user = $userid; ?>
<br><br><br>
<div align="center">
<table width="35%" border="1" cellspacing="0" cellpadding="5">
  <tr>
    <td colspan="2" align="center"><h1>Administration Menu</h1></td>
  </tr>
  <tr>
    <td colspan="2" align="center">What do you want to do?</td>
  </tr>
  <tr>
    <td>List weekly jobs.</td>
    <td><a href="jobs.php">GO!</a></td>
  </tr>

<?php ob_end_flush(); ?>

[/php]

Results in Chrome by looking at page source:

Hockey Pool Headquarters
Hockey Pool Headquarters October 19, 2015

You should start the session before the headers are sent so move your session_start(); to the top of the file.

What is this for?

[php] $userid =& $_POST[“userid”];
$password =& $_POST[“password”];[/php]

Also, why are you turning a lot of the page into an object? Are you passing this to another routine to
be displayed? Do you understand what creating an object and then just flushing out to the browser does?
I doubt you need that.

Sponsor our Newsletter | Privacy Policy | Terms of Service