Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Another login script with header problems..

Status
Not open for further replies.

frummel

Technical User
Jun 21, 2002
91
NL
Hi there, I found the following login script at but I have another header problem...
I could use some help to fix this one, because I have no clue how to rearrange the script...
Here's the page that that is giving me headaches:

-----------------
<?

// filename --> login.include.php

/*

Enjoy and don't forget to credit ME!

*/

function checkCookie() {
global $prog, $xEasyAdmin;
global $HTTP_SERVER_VARS;

if ($xEasyAdmin == $prog[validate]) { // cookie is set!
return true;
}else{
return;
}
}

function makeCookie($days) {
global $prog, $xEasyAdmin;
setcookie(&quot;xEasyAdmin&quot;, $prog[validate], time() + (3600 * $days));
}

function removeCookie() {
global $prog, $xEasyAdmin;
setcookie(&quot;xEasyAdmin&quot;, &quot;0&quot;, time() - 3600);
}

function showLoginDenied() {
// echo &quot;Sorry your login was unsuccessfull please try again...<br>\r\n&quot;;&quot;;
// echo &quot;<a href=\&quot;login.php\&quot;>Login here</a>\r\n&quot;;
header(&quot;location: login.php&quot;);
}


function showLogin() {
global $prog;

echo &quot;<h1>&quot; . $prog[title] . &quot;</h1>\r\n&quot;;
echo &quot;<form action=\&quot;$prog[program]\&quot; method=\&quot;post\&quot;><table width=\&quot;500\&quot; bgcolor=\&quot;#ccccff\&quot;>\r\n&quot;;
echo &quot;<tr bgcolor=\&quot;#ffffff\&quot;><td>Username</td><td><input type=\&quot;text\&quot; size=\&quot;25\&quot; name=\&quot;xAdminName\&quot;></td></tr>\r\n&quot;;
echo &quot;<tr bgcolor=\&quot;#ffffff\&quot;><td>Password</td><td><input type=\&quot;password\&quot; size=\&quot;25\&quot; name=\&quot;xAdminPass\&quot;></td></tr>\r\n&quot;;
echo &quot;<tr bgcolor=\&quot;#ffffff\&quot;><td><input type=\&quot;submit\&quot; name=\&quot;xAdminSubmit\&quot; value=\&quot;Submit\&quot;></td></tr>\r\n&quot;;
echo &quot;</table></form>\r\n&quot;;
}

function showLogout() {
global $prog;

echo &quot;<h1>&quot; . $prog[title] . &quot;</h1>\r\n&quot;;
echo &quot;<form action=\&quot;$prog[program]\&quot; method=\&quot;post\&quot;><table width=\&quot;500\&quot; bgcolor=\&quot;#ccccff\&quot;>\r\n&quot;;
echo &quot;<tr bgcolor=\&quot;#ffffff\&quot;><td><input type=\&quot;submit\&quot; name=\&quot;xAdminSubmit\&quot; value=\&quot;Logout\&quot;></td></tr>\r\n&quot;;
echo &quot;</table></form>\r\n&quot;;
}

function checkLogin() {
global $prog, $xAdminName, $xAdminPass;

if ($prog[username] == $xAdminName && $prog[password] == $xAdminPass) {
return true; // login successfull
}
}


$prog[username] = &quot;admin&quot;;
$prog[password] = &quot;qwerty&quot;;
$prog[title] = &quot;xEasyLogin v1.0 by ChandlerFOK&quot;;
$prog[validate] = &quot;xEasyLoginCookie&quot;;

?>
---------------

The bold line is the line that's causing me trouble..
Anyone?
 
Could you post the whole page? I bet there is an output before you do the header-call, what is not correct. You must issue a header-call only before outputting anything.

cu, Sascha cu, Sascha
 
Take out all your blank lines too, these generate page headers before your header() function gets its turn. ______________________________________________________________________
There's no present like the time, they say. - Henry's Cat.
 
But how do I rearrange it then?
I don't have the knowledge to do so....
I don't know the 'basics' so to speak....
So you say the header must come at the top of the page. But then the script doesn't make sense anymore....
 
The header() must be the first thing that occurs:
function goheader(){
header(&quot;location: login.php?loginfailed=1&quot;);
}

and from login.php check :
if ($loginfailed == 1){
echo error;
}else{
normal page
}

-----------------------------------------------------------
<?
// filename --> login.include.php
/*
Enjoy and don't forget to credit ME!
*/
function checkCookie() {
global $prog, $xEasyAdmin;
global $HTTP_SERVER_VARS;
if ($xEasyAdmin == $prog[validate]) { // cookie is set!
return true;
}else{
return;
}
}
function makeCookie($days) {
global $prog, $xEasyAdmin;
setcookie(&quot;xEasyAdmin&quot;, $prog[validate], time() + (3600 * $days));
}
function removeCookie() {
global $prog, $xEasyAdmin;
setcookie(&quot;xEasyAdmin&quot;, &quot;0&quot;, time() - 3600);
}
function showLoginDenied() {
// echo &quot;Sorry your login was unsuccessfull please try again...<br>\r\n&quot;;&quot;;
// echo &quot;<a href=\&quot;login.php\&quot;>Login here</a>\r\n&quot;;
header(&quot;location: login.php&quot;);
}
function showLogin() {
global $prog;
echo &quot;<h1>&quot; . $prog[title] . &quot;</h1>\r\n&quot;;
echo &quot;<form action=\&quot;$prog[program]\&quot; method=\&quot;post\&quot;><table width=\&quot;500\&quot; bgcolor=\&quot;#ccccff\&quot;>\r\n&quot;;
echo &quot;<tr bgcolor=\&quot;#ffffff\&quot;><td>Username</td><td><input type=\&quot;text\&quot; size=\&quot;25\&quot; name=\&quot;xAdminName\&quot;></td></tr>\r\n&quot;;
echo &quot;<tr bgcolor=\&quot;#ffffff\&quot;><td>Password</td><td><input type=\&quot;password\&quot; size=\&quot;25\&quot; name=\&quot;xAdminPass\&quot;></td></tr>\r\n&quot;;
echo &quot;<tr bgcolor=\&quot;#ffffff\&quot;><td><input type=\&quot;submit\&quot; name=\&quot;xAdminSubmit\&quot; value=\&quot;Submit\&quot;></td></tr>\r\n&quot;;
echo &quot;</table></form>\r\n&quot;;
}
function showLogout() {
global $prog;
echo &quot;<h1>&quot; . $prog[title] . &quot;</h1>\r\n&quot;;
echo &quot;<form action=\&quot;$prog[program]\&quot; method=\&quot;post\&quot;><table width=\&quot;500\&quot; bgcolor=\&quot;#ccccff\&quot;>\r\n&quot;;
echo &quot;<tr bgcolor=\&quot;#ffffff\&quot;><td><input type=\&quot;submit\&quot; name=\&quot;xAdminSubmit\&quot; value=\&quot;Logout\&quot;></td></tr>\r\n&quot;;
echo &quot;</table></form>\r\n&quot;;
}
function checkLogin() {
global $prog, $xAdminName, $xAdminPass;
if ($prog[username] == $xAdminName && $prog[password] == $xAdminPass) {
return true; // login successfull
}
}
$prog[username] = &quot;admin&quot;;
$prog[password] = &quot;qwerty&quot;;
$prog[title] = &quot;xEasyLogin v1.0 by ChandlerFOK&quot;;
$prog[validate] = &quot;xEasyLoginCookie&quot;;
?> ______________________________________________________________________
There's no present like the time, they say. - Henry's Cat.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top