Beruflich Dokumente
Kultur Dokumente
...
$_SESSION['log'] = true;
$_SESSION['username'] = $username;
?>
</form>
So, if the user click on the Go back button, the main.php page is called. Can I do
the same thing but without having a button? I mean, I want to re-direct my page to
main.php but no when the users do something (click a button or a link like href).
Thank you
--------------------------------------------------------------------------------
<?php
header("Location: http://www.example.com/"); /* Redirect browser */
/* Make sure that code below does not get executed when we redirect. */
exit;
?>
If you do this your script must not emit any html code.
--------------------------------------------------------------------------------
<html>
<head>
<link rel="stylesheet" type="text/css" href="mystyle.css"/>
<title>Demo</title>
</head>
<body>
<div id="container">
<div id="header"><?php require('header.php'); ?></div>
<div id="topnav"><?php require('topnav.php'); ?></div>
<div id="sidenav"><?php require('sidenav.php'); ?></div>
<?php
$what=$_GET['what'];
if(...){
header( 'refresh: 0; url=http://www.csd.abdn.ac.uk' ); ------> this is line 35
exit;
}
...
<?php
session_start();
?>
<div id="login">
<?php
if (!isset($_SESSION['log'])) {
$_SESSION['log'] = false;
echo("not defined");
}
else{
echo("defined");
}
if($_SESSION['log']==false){ /*not logged in*/
?>
<form method="post" action=info.php?what=login>
<br>Username: <input class="inputStyle" type=text name="username"></br>
<br>Password: <input class="inputStyle" type=password name="password"></br>
<br><input class="submitStyle" type=submit value="Login"></br>
</form>
<br><a href=info.php?what=forgot>Forgot password?</a></br>
<br><a href=info.php?what=register>Not a member? Click here for more information
to register</a></br>
<?php
}
else { /*logged in*/
echo ("Welcome jkljl
<br><a href=info.php?what=logout>Logout</a> |
<a href=info.php?what=profile>My profile</a></br>");
}
/*$_SESSION['username']*/
?>
</div>
...
The sidenav.php line 78 is the last line of the file and it isn't any code in this
line.
Do you know why it doesn't work?
Thanks
--------------------------------------------------------------------------------
Make sure your first PHP tag is a the very top of the page and there is no
preceeding whitespace. You use the header function before you output any HTML.
On the very first line of your script, open an output buffer:<?php ob_start();
Again make sure there is no preceeding white space and this is the first line of
your script. Once you have made a call to ob_start(), you can use the header
function anywhere in your code. Regardless of whether or not you have preduced any
output.
--------------------------------------------------------------------------------
codeguru.com