Search
Left Quote    You have to THINK anyway, so why not think BIG?
- Donald Trump    
Right Quote
 
[login] | [Register]
Forum Index » PHP and mySQL » Viewing Topic and Replies
Post Reply


        Viewing Topic: "Complete Member System Sample"
  This user is offline  retarded
  Subject: "re: Complete Member System Sample" Posted: @ 3:51 pm on Jun 26 2007    
Member #: 357
Rank: User - (18)
Since: 06/26/07
Posts: 22

OK i did that.. and now i have another error. which is still pointing towards my header statement.

Im gona post my header script below and my login script..

Login.php
========
Code:

<?php
ob_start();
require_once($_ SERVER['DOCUME NT_ROOT'].'/d b_connect.php' );
?>

<!DOCTYPE html PUBLIC "-//W3C// DTD XHTML 1.0 Transitional//E N" "http://w ww.w3.org/TR/xh tml1/DTD/xhtml1 -transitional.d td">
<html xmlns="ht tp://www.w3.org /1999/xhtml&qu ot;>
<head>
<meta http-equiv=&qu ot;Content-Type " content=" text/html; charset=utf-8& quot; />
<title>Ga merElites.com/L ogin</title& gt;
</head>

<body>
<?php

if(isset($_SESS ION['username ']) && isset($_SESSION ['password']) ) {
//REDIRECT TO USERS PROFILE...
header("L ocation: http://www.game relites.com/&q uot;;
} //end if logged in
//IF SUBMIT BUTTON PRESSED
if(isset($_POST ['submit'])) {

if(!$_POST['us ername']) die("Erro r: You must enter your username before logging in.";
if(!$_POST['pa ssword']) die("Erro r: You must enter your password before logging in.";

//set cookie if checked
if(!empty($_POS T['stay_in']) ) {
$joined =''.$_POST[' username'].'[ ]'.md5($_POST[ 'password']). '';
setcookie('log in_cookie', $joined, 2147483647, '/', 'http://www.ga merelites.com' );
} //end if
//verify user...
$get_user = mysql_query(&q uot;SELECT * FROM `members` WHERE username = '".$_POS T['username'] ."' AND

user_password = '".md5($ _POST['passwor d'])."' ";
$q = mysql_fetch_obj ect($get_user);
if(!$q) die("Logi n Failure: An error occured, please verify that your username and password are correct." ;
//set session variables
$_SESSION['log ged_in'] = 1;
$_SESSION['use rname'] = $_POST['userna me'];
$_SESSION['pas sword'] = $_POST['passwo rd'];
session_write_c lose();

header("L ocation: http://www.game relites.com&qu ot;;
} else {
//show login form
?>
<form name="log in" method="p ost" action="& lt;? $_SERVER['PHP_ SELF']; ?>"> ;
<table>
<tr>
<td>Usern ame:<input type="tex t" id="usern ame" name="use rname"> ;</td>
</tr>
<tr>
<td>Passw ord:<input type="pas sword" id="passw ord" name="pas sword"> ;</td>
</tr>
<tr>
<td>Submi t: <input type="sub mit" value="Su bmit" name="sub mit" id="submi t">< ;/td>
</tr>
<tr>
<td>Remem ber? <input type="che ckbox" name="sta y_in[]" checked=" yes">& lt;/td>
</tr>
</table>
</form>
<?php
}//end else
?>

</body>
</html>



and here is my header statement. i called the script
page_header.php

Code:
<!DOCTYPE html PUBLIC "-//W3C// DTD XHTML 1.0 Transitional//E N" "http://w ww.w3.org/TR/xh tml1/DTD/xhtml1 -transitional.d td"> <html xmlns="ht tp://www.w3.org /1999/xhtml&qu ot;>
<head>
<meta http-equiv=&qu ot;Content-Type " content=" text/html; charset=utf-8& quot; />
<title>pa geheader</ti tle>
</head>
<body>< ;?
ob_start();
session_start( );
require_once($_ SERVER['DOCUME NT_ROOT'].'/d b_connect.php' );

//check cookie
if ($_SESSION['lo gged_in'] != 1 && isset($_COOKIE[ 'login_cookie '])) {
list($user, $pass) = explode('[]', $_COOKIE['logi n_cookie']); $qu = mysql_query(&q uot;SELECT `user_password` FROM `members` WHERE `username` = '".addsl ashes($user).& quot;'") ;
if (mysql_num_rows ($qu) == 1) {
$passw = mysql_fetch_obj ect($qu);
if ($passw->use r_password == $pass) {
$_SESSION['log ged_in'] = 1;
$_SESSION['use rname'] = $user;
$_SESSION['pas sword'] = $pass;
}
}
}

if(!isset($_SES SION['username ']) && !isset($_SESSIO N['password'] )) {
$_SESSION['log ged_in'] = 0;
$user = "Guest&q uot;;
}
?>

</body> </html>



The error im having is
Warning: Cannot modify header information - headers already sent by (output started at /home/gamereli/ public_html/log in.php:8) in /home/gamereli/ public_html/log in.php on line 25

Warning: Cannot modify header information - headers already sent by (output started at /home/gamereli/ public_html/log in.php:8) in /home/gamereli/ public_html/log in.php on line 39


This is line 25 : setcookie('log in_cookie', $joined, 2147483647, '/', 'http://www.ga merelites.com' );

This is line 39 : header("L ocation: http://www.game relites.com&qu ot;);



Thanks for the quick response... I chose the name well i think.. describes me good, :)



    Viewed: 1,196 Times | Reply to This | To top
  This user is offline  bs0d
  Subject: "re: Complete Member System Sample" Posted: @ 4:08 pm on Jun 26 2007    

Member #: 1
Rank: Admin. - (1,506)
Since: 02/06/05
Posts: 600
From: USA

Easy, remove ob_start(); that is above session_start() ; in your page_header page, and move it to the top of the page like your login script. So the fist line is: <? ob_start(); ?> then <HTML>... bla bla bla




-bs0d | AllSyntax.com

    Viewed: 1,191 Times | Reply to This | To top
  This user is offline  retarded
  Subject: "re: Complete Member System Sample" Posted: @ 1:55 am on Jun 27 2007    
Member #: 357
Rank: User - (18)
Since: 06/26/07
Posts: 22

lol i did that to my login page and i think it worked.. because after i submit it it goes to my index page instead of giving me that error..
So i guess it works.. AWESOME!!! im proud now.. 2 weeks of tutorials.. and great help from this website, and i got my first php login script done.. Great website, great people..




    Viewed: 1,186 Times | Reply to This | To top
  This user is offline  WintersDance
  Subject: "re: Complete Member System Sample" Posted: @ 2:57 am on Jun 27 2007    

Member #: 353
Rank: User - (27)
Since: 06/19/07
Posts: 36
From: California

good luck on your website




wintersdance |     Viewed: 1,182 Times | Reply to This | To top
  This user is offline  retarded
  Subject: "re: Complete Member System Sample" Posted: @ 3:18 am on Jun 27 2007    
Member #: 357
Rank: User - (18)
Since: 06/26/07
Posts: 22

  WintersDance said...

< i> good luck on your website
lol thanks.... but im not done yet.. to bad you guys impressed me... il be back for all my php needs




    Viewed: 1,179 Times | Reply to This | To top
  This user is offline  bs0d
  Subject: "re: Complete Member System Sample" Posted: @ 3:22 am on Jun 27 2007    

Member #: 1
Rank: Admin. - (1,506)
Since: 02/06/05
Posts: 600
From: USA

That's the purpose of the site! Glad you've been able to learn from what is available.




-bs0d | AllSyntax.com

    Viewed: 1,176 Times | Reply to This | To top
Viewing Page: 2 of 2


« Prev.
1 | 2 |

You must be logged in to post on the forums. Login or Register








"AllSyntax.com" Copyright © 2002-2019; All rights lefted, all lefts righted.
Privacy Policy  |  Internet Rank