Jump to content

help with page redirection


gammaman

Recommended Posts

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

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.  ;D

Hope that helps.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.