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>"; } ?> Link to comment https://forums.phpfreaks.com/topic/103720-help-with-page-redirection/ 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. Link to comment https://forums.phpfreaks.com/topic/103720-help-with-page-redirection/#findComment-531045 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. Link to comment https://forums.phpfreaks.com/topic/103720-help-with-page-redirection/#findComment-531079 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; } Link to comment https://forums.phpfreaks.com/topic/103720-help-with-page-redirection/#findComment-531082 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.