gammaman Posted May 1, 2008 Share Posted May 1, 2008 When a user tries to access this page without logging in, it successfully sends redirects them back to the login. <?php session_start(); if($_SESSION['allowed']!=1){ header('location:studentlog.php'); } $Conn=mysql_connect("localhost","fierm","13183"); if(!$Conn){ echo "failed"; } else{ mysql_select_db("fierm"); echo "<a href=\"addCourse.php\">Add Courses</a>"; echo "<br />"; echo "<a href=\"addStudent.php\">Add Student</a>"; echo "<br />"; echo "<a href=\"addGrades.php\">Input Grades</a>"; } ?> When I try to do the same thing on this page, it does not redirect and gives the user access. <?php session_start(); if($_SESSION['allowed']!=1){ header('location:studentlog.php'); } $Conn=mysql_connect("localhost","fierm","13183"); if(!$Conn){ echo "failed"; } else{ mysql_select_db("fierm"); echo "<table border=\"1\">"; echo "<b>Registered Courses</b>"; echo "<tr><th>CourseID</th><th>CourseName</th><th>Grade</th></tr>"; $result1=mysql_query("select CourseID,CourseName,StudentID,Grade FROM Rcourse WHERE StudentID='{$_SESSION['user']}'"); $cou=mysql_num_rows($result1); while($row=mysql_fetch_array($result1)) { echo "<tr><td>$row[0]</td><td>$row[1]</td><td>$row[3]</td></tr>\n"; } echo "</table>"; echo "<b>Register For Courses:</b>"; echo "<br />"; echo "<a href=\"regCourse.php\">Register Courses</a>"; echo "<br/>"; echo "<b>Drop a Course</b>"; echo "<br/>"; echo "<a href=\"dropCourse.php\">Drop a Course</a>"; } ?> Quote Link to comment Share on other sites More sharing options...
gammaman Posted May 1, 2008 Author Share Posted May 1, 2008 It seems to work now and the only thing I changed in the file was the deletion of two blank lines at the top of the file, Is that even possible. Quote Link to comment Share on other sites More sharing options...
Fearpig Posted May 1, 2008 Share Posted May 1, 2008 It all depends on the software you are editing with! Some software will insert a carridge return instead of a blank line, the problem with this is that NOTHING should be sent before the header even if it is junk! I'm fairly sure thats right but I'll wait a while and see if I get corrected. Hope that helps. Quote Link to comment Share on other sites More sharing options...
benphp Posted May 1, 2008 Share Posted May 1, 2008 Try this: if($_SESSION['allowed']!=1){ header('location:studentlog.php'); exit; } Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.