Jump to content

proper login page layout ot avoid header errors.


calmchess

Recommended Posts

I tried to follow the guidelines to avoiding header errors but i still get them can you tell me what i'm doing wrong?

<?php session_start();
      //ob_start(1);?>
<!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" xml:lang="en" lang="en">
<html>
<head>


<style type="text/css">
<!-- body{ margin: 0; padding:0; text-align:center; }
#c-block {width:100%; height:80%;border:1px solid red;}
.c-col{width:723px; height:800px; margin-left:auto;margin-right:auto;border:1px solid blue;}
#hdr{height:80px; width:100%; margin:0;border:1px solid green;}
.ftr{ width:100%;height:35px; border-top:1px solid black;text-align:center;}
.cenbox{width:210px;height:70px;margin-left:auto;margin-right:auto;margin-top:170px;border:1px solid purple;text-align:center;}
#errtxt{color:red;margin-left:8px;}
-->
</style>
  <?php 
include("../../secure_php/mod_database.php");

function getmodname($mod,$pass){
$callname = getU($mod);
if($callname!=0){
$callpass=getUPass($mod,$pass);
}else{
return 0;
}
if($callpass ==1){
return 1;
}else{
return 0;
}
}


if(isset($_SESSION['nCG0nX'])){
//display swf
unset($_SESSION['nCG0nX']);
}else{
displaylogin();
}
if(isset($_POST['sublogin'])){

$authmod=getmodname($_POST['name'],md5($_POST['pass']));
echo $authmod;
if($authmod == 1){
$_SESSION['nCG0nX']=true;
header('Location: http://privatechatnow.com/yahoo_video_chat/models/login/adlogin.php');
}else{
unset($_SESSION['nCG0nX']);
//displaylogin();
$_SESSION['err0']="<small id=errtxt>The Username or Password is Incorrect </small>";
header('Location: http://privatechatnow.com/yahoo_video_chat/models/login/adlogin.php');
}
}      
?>
</head>
<?php
function displaylogin(){
?>
<body>
<div id ="hdr"></div>
<div id="c-block">
<div class="c-col">

<div class="cenbox">
<?php 
if(isset($_SESSION['err0'])){
echo $_SESSION['err0'];
unset($_SESSION['err0']);
}
?>
<form action="" method="POST">
<table align="left" border="0" cellspacing="0" cellpadding="3">
<tr><td>Username:</td><td><input  type="text" name="name" maxlength="30"></td></tr>
<tr><td>Password:</td><td><input  type="password" name="pass" maxlength="30"></td></tr>
<tr><td colspan="2" class="aliright"><input type="submit" name="sublogin" value="Login"></td></tr>
</table>
</form>
</div>
</div>
<div class="ftr"  ><a href="">Privacy</a>&nbsp|
<a href="">Advertise with us</a>&nbsp|&nbsp<a href="">About us</a>&nbsp|&nbsp
<a href="" >Contact Us</a>&nbsp|&nbsp<a href="">Help</a>
<div><a href ="">18 U.S.C. 2257 Information Record Keeping Requirements Compliance Statement</a></div>
<div><small>Copyright © 2010--2010 privatechatnow.com. All Rights Reserved.</small></div></div>
    
</div>
</body>

<?php

}
?>

</html>

Well, for one:

 

<!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" xml:lang="en" lang="en">

<html>

<head>

 

 

<style type="text/css">

<!-- body{ margin: 0; padding:0; text-align:center; }

#c-block {width:100%; height:80%;border:1px solid red;}

.c-col{width:723px; height:800px; margin-left:auto;margin-right:auto;border:1px solid blue;}

#hdr{height:80px; width:100%; margin:0;border:1px solid green;}

.ftr{ width:100%;height:35px; border-top:1px solid black;text-align:center;}

.cenbox{width:210px;height:70px;margin-left:auto;margin-right:auto;margin-top:170px;border:1px solid purple;text-align:center;}

#errtxt{color:red;margin-left:8px;}

-->

</style>

 

Your displaying that and then trying to use

 

header("Location");

 

What I do is put that stuff in a variable called $Top, then only display $Top in cases when I'm not going to make changes to the header, IE, locations

The logic that determines if you are going to stay on a page or redirect must come first.

 

There's no point in outputting anything on a page (even the doctype...) if you are not even going to stay on that page. It just wastes processing time and if you could actually output content before a redirect, it would waste your bandwidth every time you did it.

 

Only output content if you are going to stay on the page.

 

Where does your current error message state the output is occurring at, because you could also have a problem with the UTF-8 BOM (Byte Order Mark) characters that editors place at the start of a file.

Ok got rid of the nasty header errors how does this look for cleanliness and flow?

 

 

<?php session_start();
$top ="
<!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 xml:lang=en lang=en>
<html>
<head>
<title>Hot Model</title>
<META name=keywords content=webcam, webcams, cam, cams, live>
<META name=robots content=index,follow>
  <META name=revisit-after content=10>
  <META name=robots content=all>
  <meta name=author content=calmchess >
  <META name=page-topic content=Hot Live Webcams>
  <META name=copyright content=privatechatnow.com,2010>
  <META name=distribution content=global>
  <META name=ABSTRACT CONTENT=privatechatnow.com - Live video cam and chat>
  <META name=rating content=Mature> 
<style type=text/css>
<!-- body{ margin: 0; padding:0; text-align:center; }
#c-block {width:100%; height:80%;border:1px solid red;}
.c-col{width:723px; height:800px; margin-left:auto;margin-right:auto;border:1px solid blue;}
#hdr{height:80px; width:100%; margin:0;border:1px solid green;}
.ftr{ width:100%;height:35px; border-top:1px solid black;text-align:center;}
.cenbox{width:250px;height:70px;margin-left:auto;margin-right:auto;margin-top:170px;border:1px solid purple;text-align:center;}
#errtxt{color:red;margin-left:8px;}
-->
</style>";
  
include("../../secure_php/mod_database.php");

function getmodname($mod,$pass){
$callname = getU($mod);
if($callname!=0){
$callpass=getUPass($mod,$pass);
}else{
return 0;
}
if($callpass ==1){
return 1;
}else{
return 0;
}
}
if(isset($_SESSION['nCG0nX'])){
//display swf
unset($_SESSION['err0']);
unset($_SESSION['nCG0nX']);
return;
}else{
//displaylogin();
}
if(isset($_POST['sublogin'])){

$authmod=getmodname($_POST['name'],md5($_POST['pass']));
if($authmod == 1){
$_SESSION['nCG0nX']=true;
header('Location: http://www.privatechatnow.com/yahoo_video_chat/models/login/adlogin.php');
}else{
unset($_SESSION['nCG0nX']);
$_SESSION['err0']="<small id=errtxt>The Username or Password is Incorrect </small>";
header('Location: http://www.privatechatnow.com/yahoo_video_chat/models/login/adlogin.php');
}
}else{
echo $top;
}      
?>
</head>
<?php
//function displaylogin(){
?>
<body>
<div id ="hdr"></div>
<div id="c-block">
<div class="c-col">

<div class="cenbox">
<?php 
if(isset($_SESSION['err0'])){
echo $_SESSION['err0'];
}
?>
<form action="" method="POST">
<table align="left" border="0" cellspacing="0" cellpadding="3">
<tr><td>Username:</td><td><input  type="text" name="name" maxlength="30"></td></tr>
<tr><td>Password:</td><td><input  type=password name=pass maxlength="30"></td></tr>
<tr><td colspan=2 class="aliright"><input type="submit" name="sublogin" value="Login"></td></tr>
</table>
</form>
</div>
</div>
<div class="ftr"  ><a href="">Privacy</a>&nbsp|
<a href="">Advertise with us</a>&nbsp|&nbsp<a href=>About us</a>&nbsp|&nbsp
<a href="" >Contact Us</a>&nbsp|&nbsp<a href="">Help</a>
<div><a href ="">18 U.S.C. 2257 Information Record Keeping Requirements Compliance Statement</a></div>
<div><small>Copyright © 2010--2010 privatechatnow.com. All Rights Reserved.</small></div></div>
  
</div>
</body>
</html>
[code]

The error message tells you where the output is occurring at that is preventing the header() from working. You then read the error message and look at your code where that output is at in order to determine what is causing that output so that you can fix the problem.

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.