Re: [PHP] Problem with Redirect
- From: ceo@xxxxxxxxx ("Richard Lynch")
- Date: Thu, 15 Feb 2007 22:52:02 -0600 (CST)
[Didn't I see this thread before?...]
On Thu, February 15, 2007 7:39 pm, Ashish Rizal wrote:
Hi friends, I am having problem with following code.
I have actually made the whole code on same page (login.php) and
the functions that i used in
this code are in functions.php. Now this time it is showing the
warning :
Warning: Cannot modify header information - headers already sent
by (output started at C:\Program
Files\xampp\htdocs\fselection\login.php:1) in C:\Program
Files\xampp\htdocs\fselection\login.php on line 19
The line 19 is header("Location: http://$host$uri/$extra");
Below is the list of code for login.php.
The Server i am using is SunOS 5.10.
<?php
session_start();
require_once 'functions.php';
$UserName = $_POST['UserName'];
$Password = $_POST['Password'];
$host = $_SERVER['HTTP_HOST'];
$uri = rtrim(dirname($_SERVER['PHP_SELF']), '/\\');
$extra = 'adminlogin.php';
$loc = "\"http://$host$uri/$extra\"";
if ($_POST){
$error = login_check($_POST);
if (trim ($error)=="")
{
$accesslevel = accessLevel($UserName);
?>
<?php
//At a minimum, you need to do this here:
session_write_close();
if ($accesslevel == "admin"){
$_SESSION["userid"] = login($_POST);
header("Location: http://$host$uri/$extra");
exit();
}
else if ($accesslevel == "user") {
//echo "this is user";
$_SESSION["userid"] = login($_POST);
header('Location: userlogin.php');
exit();
}
}
else {
print "Error :$error";
}
You could also consider not doing a redirect at all, and just suck in
the appropriate files with 'include' instead of wasting HTTP
connections and bouncing the user like a basketball just to give them
what they want...
PS
exit is not a function and should not have ()
PPS
Blindly cramming all of $_POST into a session variable is a
particularly Bad Idea from a security standpoint, and you need to
study everything on this site before proceeeding:
http://phpsec.org/
--
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?
.
- References:
- Problem with Redirect
- From: "Ashish Rizal"
- Problem with Redirect
- Prev by Date: Problem with Redirect
- Next by Date: array_pop() with key-value pair ???
- Previous by thread: Problem with Redirect
- Next by thread: Re: [PHP] Problem with Redirect
- Index(es):
Relevant Pages
|