Search
Left Quote    Nearly all men can stand adversity, but if you want to test a man's character, give him power.
- Abraham Lincoln    
Right Quote
 
[login] | [Register]
Forum Index » PHP and mySQL » Viewing Topic and Replies
Post Reply


        Viewing Topic: Complete Member system tutorial help
  This user is offline  Burkaano
  Subject: "Complete Member system tutorial hel..." Posted: @ 9:31 pm on Feb 26 2007   
Member #: 287
Rank: User - (2)
Since: 02/26/07
Posts: 2

Hi, i need some help with this tutorial..

I had a big problems with headers, always showed that headers already sent. Then i tried put this
Code:
<?php
ob_start();
?>
<?php
ob_end_flush();
?>

in index.php and logout.php

Then it worked.. But not for long time, now i have problems, because everyone can go to members.php without authorizing. Why that?

members.php

Code:
<?
ob_start();
session_start( );
require_once($_ SERVER['DOCUMEN T_ROOT'].'/db_c onnect.php'); include('page_h eader.php');
?>

Member INDEX

<a href="logo ut.php"> ;logout</a&g t;
?>
<?php
ob_end_flush();
?>



I need to get, that member.php is only for members and index is for unregistered.


Thanks


    Viewed: 8,618 Times | Reply to This | To top
  This user is offline  bs0d
  Subject: "re: Complete Member system tutorial..." Posted: @ 11:49 pm on Feb 26 2007    

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

Ok then, on your members.php page, say:

Code:


<?
if($_SESSION[' logged_in'] != 1) {
die("Warn ing: You must be logged in or a member to view this page.";
} //end if
?>


This will prevent visitors or members not signed in from viewing the page. This session variable is setup in the Complete Members System article.

Edit: Also, I don't believe you need ob_end_flush();

 kriek at jonkriek dot com (from PHP.NET) said...
< i>ob_end_f lush() isn't needed in MOST cases because it is called automatically at the end of script execution by PHP itself when output buffering is turned on either in the php.ini or by calling ob_start().



Edited at 11:53:25 pm on 02/26/07


-bs0d | AllSyntax.com

    Viewed: 8,613 Times | Reply to This | To top
  This user is offline  Burkaano
  Subject: "re: Complete Member system tutorial..." Posted: @ 7:00 pm on Feb 27 2007    
Member #: 287
Rank: User - (2)
Since: 02/26/07
Posts: 2

Thank you very much, but

something wrong with my cookies.. or idk where is problem, because i can't log in :(


Code:

<html>
<head>
<title>&l t;/title>
</head>
<body>

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

if(isset($_SESS ION['username ']) && isset($_SESSION ['password']) ) {
//REDIRECT TO USERS PROFILE...
header("L ocation: http://217.199. 102.190/l/&quo t;
} //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, '/', 'NA');
} //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 your username and password are correct."< img src=http://www. allsyntax.com/f orums/images/sm ilies/wink.gif border=0>;

//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://217.199. 102.190/l/membe rs.php";

} 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>< br /> </form> <?
}//end else
?>

</body>
</html>



Edited at 07:05:13 pm on 02/27/07


    Viewed: 8,591 Times | Reply to This | To top
  This user is offline  bs0d
  Subject: "re: Complete Member system tutorial..." Posted: @ 10:17 pm on Feb 27 2007    

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

I didn't have a chance to read all through your code, but right off the top here <? ob_start(); ?> should be your first line of code on your page, even before <HTML>. Also, on your set_cookie function, I believe that 'N/A' should be your website.




-bs0d | AllSyntax.com

    Viewed: 8,581 Times | Reply to This | To top
Viewing Page: 1 of 1


1 |

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








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