Search
Left Quote    Copy from one, it's plagiarism; copy from two, it's research.
- Wilson Mizner    
Right Quote
 
[login] | [Register]
Forum Index » PHP and mySQL » Viewing Topic and Replies
Post Reply


        Viewing Topic: login workin, almost....
  This user is online  Guest
  Subject: "login workin, almost...." Posted: @ 9:41 am on Dec 07 2005   
Unregistered
hey.. i have just finnished your great tutorial. And it works, but the problem is that the content page is still accessible even if i'm not logged in, I can still type the url of the content page and it allows me access, how can i change that so it isn't accessible... thanks for a great site and great tutorials...




    Viewed: 14,812 Times | Reply to This | To top
  This user is online  Guest
  Subject: "re: login workin, almost...." Posted: @ 9:48 am on Dec 07 2005    
Unregistered

lso i should say that i have build my site with several seperate fiels, such as login.php, register.php and content.php....
i don't know if the problems are caused by that...



    Viewed: 14,806 Times | Reply to This | To top
  This user is offline  BattleSpunk
  Subject: "re: login workin, almost...." Posted: @ 9:22 am on Dec 09 2005    
Member #: 115
Rank: User - (1)
Since: 12/09/05
Posts: 1
From: Australia

<?php

if($_SESSION[' logged_in'] != 1)
{
echo("T his is the content."< img src=http://www. allsyntax.com/f orums/images/sm ilies/wink.gif border=0>;
} else {
echo("Y ou need to log in.";
}
?>




battlespunk@gma
il.com | battlespunk |     Viewed: 14,792 Times | Reply to This | To top
  This user is online  Guest
  Subject: "re: login workin, almost...." Posted: @ 1:49 pm on Dec 09 2005    
Unregistered

thanks, but where should i post that code...



    Viewed: 14,786 Times | Reply to This | To top
  This user is online  Guest
  Subject: "re: login workin, almost...." Posted: @ 9:57 am on Dec 12 2005    
Unregistered

that code doesn't work, somehow i still can access my content site with out being logged in...

anybody got any suggestions... ?? please help...



    Viewed: 14,775 Times | Reply to This | To top
  This user is online  Guest
  Subject: "re: login workin, almost...." Posted: @ 12:45 pm on Dec 12 2005    
Unregistered

also when using the above code, i get an error sayin :

Parse error: parse error, unexpected '<' in /usr/home/web/w eb67011/haps.ph p on line 6

which is the line :

echo("Thi s is the content." ;

Italic Text Here



    Viewed: 14,772 Times | Reply to This | To top
  This user is offline  bs0d
  Subject: "re: login workin, almost...." Posted: @ 1:12 pm on Dec 12 2005    

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

where he has "this is the content" put the code for whatever you wanting hidden




-bs0d | AllSyntax.com

    Viewed: 14,769 Times | Reply to This | To top
  This user is online  Guest
  Subject: "re: login workin, almost...." Posted: @ 1:31 pm on Dec 12 2005    
Unregistered

i'm sorry i dont' quite folow you!!! what code is that??



    Viewed: 14,767 Times | Reply to This | To top
  This user is online  Guest
  Subject: "re: login workin, almost...." Posted: @ 3:14 pm on Dec 12 2005    
Unregistered

made it work.... but now i can't seem to it appear, when i'm logged in.. why's that....
???
thanks though......... ..............



    Viewed: 14,756 Times | Reply to This | To top
  This user is offline  bs0d
  Subject: "re: login workin, almost...." Posted: @ 6:10 pm on Dec 12 2005    

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

 Guest said...

< i>i'm sorry i dont' quite folow you!!! what code is that??


your content that you dont want displayed unless logged in. If its not showing up, make sure the session variable $_SESSION['log ged_in'] = 1; because thats the condition. if it is, show content, if not, dont.




-bs0d | AllSyntax.com

    Viewed: 14,750 Times | Reply to This | To top
  This user is online  Guest
  Subject: "re: login workin, almost...." Posted: @ 1:04 pm on Dec 14 2005    
Unregistered

still doesn't work...
now all i see is the echo line

you need to login, regardless if i'm logged in or not...

here is my code... please tell me if theres something wrong in the code
Code:

<?
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;;
}

?>
<?php

if($_SESSION[' logged_in'] != 1)
{
echo('<styl e type="tex t/css"> ;
<!--
body,td,th {
color: #FFFFFF;
}
body {
background-col or: #000000;
}
-->
</style>& lt;table width="10 0%" border="0 " cellspacing=&q uot;0" cellpadding=&q uot;0"> ;
<tr>
<td align="ce nter" valign="m iddle"> ;<object classid=" clsid27CDB6 E-AE6D-11cf-96B 8-444553540000 " codebase=" ;http://downloa d.macromedia.co m/pub/shockwave /cabs/flash/swf lash.cab#versio n=6,0,29,0&quo t; width="80 0" height="6 00"> <param name="mov ie" value="pr eloader_2.swf& quot;>
<param name="qua lity" value="hi gh"> <embed src="prel oader_2.swf&qu ot; quality=" high" pluginspage=&q uot;http://www. macromedia.com/ go/getflashplay er" type="app lication/x-shoc kwave-flash&qu ot; width="80 0" height="6 00">&l t;/embed>
</object> </td>
</tr>
</table>< br /> <p><a href="pro fil.php"& gt; Vis Profil</a> ; </p>
<p><a href="log out.php"& gt;Log ud</a>< ;/p>
<p>&n bsp;</p>< br /> .');
} else {
echo("You need to log in.";
}
?>





    Viewed: 14,737 Times | Reply to This | To top
  This user is online  Guest
  Subject: "re: login workin, almost...." Posted: @ 1:55 pm on Dec 14 2005    
Unregistered

this is my login code, maybe it's something in that file....


Code:

<?
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: haps.php"< img src=http://www. allsyntax.com/f orums/images/sm ilies/wink.gif border=0>;
} //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, '/', 'haps.php');
} //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: haps.php"< img src=http://www. allsyntax.com/f orums/images/sm ilies/wink.gif border=0>;

} else {
//show login form
?>
<form name="log in" method="p ost" action="& lt;? $_SERVER['PHP_ SELF']; ?>"> ;
<table width="15 0" height="1 43"> <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><i nput 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
?>


<table width="16 8" height="6 5" border="0 " cellpadding=&q uot;0" cellspacing=&q uot;0"> ;
<tr>
<td width="12 ">& ;nbsp;</td&g t;
<td width="36 3" align="ce nter" valign="m iddle"> ;<a href="reg ister.php" ;>Ny Bruger? Registrer nu</a>< ;/td>
<td width="11 ">& ;nbsp;</td&g t;
</tr>
</table>< br /> </body> </html>



thanks again....



    Viewed: 14,733 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