Php Redirect Help Please
Hey i have a page, which i want to redirect to a login page if, the user is not logged in.
here is the code
**********************
<?
include("include/session.php");
include_once("mysql.inc.php");
$connection = @mysql_connect($host, $user, $password) or die(mysql_error());
$db = @mysql_select_db($name,$connection) or die(mysql_error());
include("include/banner.php");
?>
<div id="chatbox">
<form id="newshout" name="newshout" action="newshout.php" method="post">
Message:<br>
<input name="shout" type="text" id="Post" size="24" maxlength="50" />
<input id="submit" name="submit" type="submit" value="post" /></form>
<?
$sql = mysql_query("SELECT * FROM `shouts` ORDER BY `shouts`.`id`");
while($data = mysql_fetch_array($sql)){
$timestamp = $data['timestamp'];
$postedyear=substr($timestamp,0,4);
$postedmonth=substr($timestamp,5,2);
$postedday=substr($timestamp,8,2);
$postedtime=substr($timestamp,11,5);
$newpostedtime = "";
$nomilitary=substr($postedtime,0,2);
if($nomilitary >= 13){
$nomilitary = $nomilitary - 12 ;
$newpostedtime = $nomilitary ;
$newpostedtime .= ":" ;
$newpostedtime .= substr($postedtime,3,2) ;
$newpostedtime .= " pm";
}
if($newpostedtime != ""){
$postedtime = $newpostedtime;
}else{
$postedtime .= " am";
}
$shoutby = $data['shoutby'];
$shout = $data['shout'];
echo "<br><br><div id='comments'><strong>" . $shoutby . "</strong>: <br><br> " . $shout . "<br><br> <div id='posted'> Posted " . $postedmonth . "/" . $postedday . "/" . $postedyear . " at " . $postedtime . "<br></div></div>";
}
?>
</div>
<?php
include("include/footer.php");
?>
*****************************
i want it to redirect to "../login/index.php"
can anyone please help me
thanks
|