Jump to content

[SOLVED] header function


jbingman

Recommended Posts

I've been trying to use the header(); function to redirect to other pages such as...

Login not successful *redirects to login page*. but whenever i try to use the header it says that its being used by another line already. and no where in my code is there another line like it. what does this error mean and how do i fix it?

Link to comment
https://forums.phpfreaks.com/topic/67561-solved-header-function/
Share on other sites

<? session_start(); ?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

 

<title>Admin</title>

<link href="/mainstyle.css" rel="stylesheet" type="text/css" />

<link rel="shortcut icon" href="favicon.ico" />

</head>

 

<body>

<?php

 

if (!$_SESSION["valid_user"])

{

// User not logged in, redirect to login page

header("location:login.php");

}

?>

<center>

<table width="895" height="134"  style="background-image:url(/Untitled-3.gif)">

  <tr>

  <th width="99"><a href="/index.shtml"><img src="/logotrans3.gif" alt="logoSAR" width="118" height="126" border="0" /></a></th>

    <th width="782" height="128" scope="col"><a href="/index.shtml"><img src="/SARtitle2.gif" alt="sartitle" width="656" height="82" border="0" /></a></th>

  </tr>

</table>

 

 

<table width="895" height="822">

<tr>

  <td width="140" height="806" valign="top"><table width="140" height="232" border="0">

      <tr>

        <th width="134" height="22" scope="row"><div align="left"><a href="http://www.fresnosar.com/index.shtml">Home</a>-</div></th>

      </tr>

      <tr>

        <th height="22" scope="row"><div align="left"><a href="http://www.fresnosar.com/about.html">About</a>-</div></th>

      </tr>

      <tr>

        <th height="22" scope="row"><div align="left"><a href="http://www.fresnosar.com/update/news.html">Current News</a>-(<a href="admin/newsedit.php">edit</a>)</div></th>

      </tr>

      <tr>

        <th height="22" scope="row"><div align="left"><a href="http://www.fresnosar.com/cal/calendar.html">Calendar</a>-(<a href="admin/caledit.php">edit</a>)</div></th>

      </tr>

      <tr>

        <th height="22" scope="row"><div align="left"><a href="http://www.fresnosar.com/photo/albums.html">Photos In Action</a>-(<a href="admin/picedit.php">add/edit</a>)</div></th>

      </tr>

      <tr>

        <th height="22" scope="row"><div align="left"><a href="http://www.fresnosar.com/vid/videos.html">Videos</a>-(<a href="admin/videdit.php">add/edit</a>)</div></th>

      </tr>

      <tr>

        <th height="22" scope="row"><div align="left"><a href="http://www.fresnosar.com/links.html">SAR Links</a>-(<a href="admin/linksedit.php">edit</a>)</div></th>

      </tr>

      <tr>

        <th height="22" scope="row"><div align="left"><a href="http://www.fresnosar.com/app/apply.html">Apply</a>-</div></th>

      </tr>

      <tr>

        <th height="20" scope="row"><div align="left"><a href="http://www.fresnosar.com/contact.html">Contact</a>-</div></th>

      </tr>

  </table></td>

  <td width="642" align="center" valign="top">

  <div class="img">

    <p>Admin Page </p>

    </div>  </td>

<td width="97" align="left" valign="top">

<?

// Display last login date

 

 

// Display logout link

echo "<p><a href=\"logout.php\">logout</a></p>";

?>

</td>

  </tr>

</table>

<table width="895" height="57">

  <tr>

    <th height="51" style="border:none"><h6><a href="http://www.fresnosar.com/index.shtml">Home</a> | <a href="http://www.fresnosar.com/about.html">About</a> | <a href="http://www.fresnosar.com/update/news.html">News</a> | <a href="http://www.fresnosar.com/cal/calendar.html">Calendar</a> | <a href="http://www.fresnosar.com/photo/albums.html">Photos</a> | <a href="http://www.fresnosar.com/vid/videos.html">Videos</a> | <a href="http://www.fresnosar.com/links.html">Links</a> | <a href="http://www.fresnosar.com/app/apply.html">Apply</a> | <a href="http://www.fresnosar.com/contact.html">Contact</a></h6>

      <h6>Copyright 2007 FrameWorks Studios <a href="mailto:[email protected]">[email protected]</a>. All rights reserved.</h6></th>

  </tr>

</table>

</center>

</body>

</html>

 

 

Try this:

 

<?php
session_start();

if (!$_SESSION["valid_user"])
{
// User not logged in, redirect to login page
header("location:login.php");

}
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>

<title>Admin</title>
<link href="/mainstyle.css" rel="stylesheet" type="text/css" />
<link rel="shortcut icon" href="favicon.ico" />
</head>

<body>

<center>
<table width="895" height="134"  style="background-image:url(/Untitled-3.gif)">
  <tr>
  <th width="99"><a href="/index.shtml"><img src="/logotrans3.gif" alt="logoSAR" width="118" height="126" border="0" />[/url]</th>
    <th width="782" height="128" scope="col"><a href="/index.shtml"><img src="/SARtitle2.gif" alt="sartitle" width="656" height="82" border="0" />[/url]</th>
  </tr>
</table>


<table width="895" height="822">
<tr>
  <td width="140" height="806" valign="top"><table width="140" height="232" border="0">
      <tr>
        <th width="134" height="22" scope="row"><div align="left">Home-</div></th>
      </tr>
      <tr>
        <th height="22" scope="row"><div align="left">About-</div></th>
      </tr>
      <tr>
        <th height="22" scope="row"><div align="left">Current News-(<a href="admin/newsedit.php">edit[/url])</div></th>
      </tr>
      <tr>
        <th height="22" scope="row"><div align="left">Calendar-(<a href="admin/caledit.php">edit[/url])</div></th>
      </tr>
      <tr>
        <th height="22" scope="row"><div align="left">Photos In Action-(<a href="admin/picedit.php">add/edit[/url])</div></th>
      </tr>
      <tr>
        <th height="22" scope="row"><div align="left">Videos-(<a href="admin/videdit.php">add/edit[/url])</div></th>
      </tr>
      <tr>
        <th height="22" scope="row"><div align="left">SAR Links-(<a href="admin/linksedit.php">edit[/url])</div></th>
      </tr>
      <tr>
        <th height="22" scope="row"><div align="left">Apply-</div></th>
      </tr>
      <tr>
        <th height="20" scope="row"><div align="left">Contact-</div></th>
      </tr>
  </table></td>
  <td width="642" align="center" valign="top">
  <div class="img">
    <p>Admin Page </p>
    </div>  </td>
<td width="97" align="left" valign="top">
<?
// Display last login date


// Display logout link
echo "<p><a href=\"logout.php\">logout[/url]</p>";
?>
</td>
  </tr>
</table>
<table width="895" height="57">
  <tr>
    <th height="51" style="border:none"><h6>Home | About | News | Calendar | Photos | Videos | Links | Apply | Contact</h6>
      <h6>Copyright 2007 FrameWorks Studios [email][email protected][/email]. All rights reserved.</h6></th>
  </tr>
</table>
</center>
</body>
</html>

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.