Search
Left Quote    By failing to prepare, you are preparing to fail.
- Benjamin Franklin    
Right Quote
 
[login] | [Register]
Forum Index » PHP and mySQL » Viewing Topic and Replies
Post Reply


        Viewing Topic: Need some help
  This user is offline  solphate
  Subject: "Need some help" Posted: @ 5:45 pm on Feb 18 2008   
Member #: 581
Rank: User - (24)
Since: 02/18/08
Posts: 24

So i just followed the tutorial on the following url http://www.all syntax.com/tuto rials/PHP/26/Co mplete-Members- System/1.php and i want to make it so that if your a visitor is shows the navbar with only login and register buttons


And if your a member you get all the buttons in the navbar except login and register but replacing those two buttons with a logout button.

If you need to look at my website then you can go to http://solphat esrealm.zxq.net

the members stuff ins't up yet but at leasy you can look at how i have the navbar setup


It me it me
    Viewed: 10,596 Times | Reply to This | To top
  This user is offline  bs0d
  Subject: "re: Need some help" Posted: @ 11:14 pm on Feb 18 2008    

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

Basically, you just setup a condition based on the variables used.

Code:


if($_SESSION[' logged_in'] == 0) {
//display "guest&q uot; stuff here.

} else {
//display member only stuff here.

} //end if




-bs0d | AllSyntax.com

    Viewed: 10,586 Times | Reply to This | To top
  This user is offline  solphate
  Subject: "re: Need some help" Posted: @ 1:48 am on Feb 19 2008    
Member #: 581
Rank: User - (24)
Since: 02/18/08
Posts: 24

Thanks Man! It just that i'm new to this php stuff



Edited at 01:49:36 am on 02/19/08


It me it me

    Viewed: 10,580 Times | Reply to This | To top
  This user is offline  solphate
  Subject: "re: Need some help" Posted: @ 3:25 am on Feb 21 2008    
Member #: 581
Rank: User - (24)
Since: 02/18/08
Posts: 24

HOw woulld i use a table with that using the "<?,?& gt;" tags?




It me it me

    Viewed: 10,549 Times | Reply to This | To top
  This user is offline  solphate
  Subject: "re: Need some help" Posted: @ 3:36 am on Feb 21 2008    
Member #: 581
Rank: User - (24)
Since: 02/18/08
Posts: 24

Never mind about my last post i fixed it now my login, register pages aren't able to access the db_connect.php file so if you can help with that please do




It me it me

    Viewed: 10,547 Times | Reply to This | To top
  This user is offline  solphate
  Subject: "re: Need some help" Posted: @ 3:51 am on Feb 21 2008    
Member #: 581
Rank: User - (24)
Since: 02/18/08
Posts: 24

When i go to open the login.php file i get this

Code:

Warning: require_once() [function.requi re-once]: Unable to access /www//connect/d b_connect.php in /www/zxq.net/s/ o/l/solphatesre alm/htdocs/logi n.php on line 3

Warning: require_once(/w ww//connect/db_ connect.php) [function.requi re-once]: failed to open stream: No such file or directory in /www/zxq.net/s/ o/l/solphatesre alm/htdocs/logi n.php on line 3

Fatal error: require_once() [function.requi re]: Failed opening required '/www//connect /db_connect.php ' (include_path= '.:/usr/share/p hp') in /www/zxq.net/s/ o/l/solphatesre alm/htdocs/logi n.php on line 3




It me it me

    Viewed: 10,544 Times | Reply to This | To top
  This user is offline  solphate
  Subject: "re: Need some help" Posted: @ 3:52 am on Feb 21 2008    
Member #: 581
Rank: User - (24)
Since: 02/18/08
Posts: 24

k bs0d there is something wrong with your members system code after eading the article and getting all the code it work but i didn't get the line <? and i got all the script text in the background. so i added the <? and it says
 web browser said...

< i>Parse error: syntax error, unexpected '`', expecting ')' in /www/zxq.net/s/ o/l/solphatesre alm/htdocs/regi ster.php on line 20


can you help me fix this problem?



Edited at 04:07:01 am on 02/21/08


It me it me

    Viewed: 10,542 Times | Reply to This | To top
  This user is offline  solphate
  Subject: "re: Need some help" Posted: @ 4:07 am on Feb 21 2008    
Member #: 581
Rank: User - (24)
Since: 02/18/08
Posts: 24

Here my register script


Code:

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

//SEE IF ALREADY LOGGED IN

if($_SESSION[ 'logged_in'] == 1)
{
//REDIRECT TO HOMEPAGE
header('Locati on: http://' . $_SERVER['HTTP _HOST'] . '');
} else {

if(isset($HTTP _POST_VARS['su bmit']))
{

//BEGIN CHECKING USERNAME...

if(!$_POST['us ername']) die('Alert: username field was blank.');

//array of invalid characters
$junk = array('.' , ',' , '/' , '\' , '`' , ';' , '[' , ']' , '-','*', '&', '^', '%', '$', '#', '@', '!', '~', '+', '(', ')' '|', '{', '}', '<', '>', '?', ':', '"', '=');
')'
//starting lenght of username
$len = strlen($_POST[ 'username']);< br />
//replace invalid characters
$_POST['userna me'] = str_replace($ju nk, '', $_POST['userna me']);
$test = $_POST['userna me'];

//if lenghts are different ($len smaller), invalid characters found, so prompt error.
if(strlen($test ) != $len) {
die('Username Error: Username contained invalid characters. You can only use A-Z, 0-9 and the

underscore (_).');
}

//Check if username already exists...

$q2 = mysql_query(&q uot;SELECT * FROM `members` WHERE `username` = '".$_POS T['username'] ."'&quo t;);
$q3 = mysql_fetch_obj ect($q2);

if($q3->user name == $_POST['userna me']) {
die('<BR&g t;<BR>Sor ry, but the username "'.$q3-& gt;username.' " is taken, please choose another.');
}

//PASSWORD

if(!$_POST['pa ssword']) {
die('Error: Password field was blank');
}
if(!$_POST['ve rify_password' ]) {
die('Error: Verify Password field was blank.');
}
if($_POST['pas sword'] != $_POST['verify _password']) {
die('Error: The passwords do not match.');
}
if(strlen($_POS T['password'] ) < 6 ) {
die('Error: Your password is too short. Must be 6 or more characters in length.');
}

//ADD NEW MEMBER

$insert ="INSERT INTO `members` (username, user_password, user_email) VALUES ('".$_PO ST['username' ]."',

'".md5($ _POST['passwor d'])."' , '".$_POS T['email'].& quot;')" ;

$insert2 = mysql_query($in sert);
if(!$insert2) die(mysql_error ());

echo('Registra tion Successful, Welcome new member! You can now login to your new account.');

} else {
?>
<table> <form name="sig nup" action="& lt;? $_SERVER['PHP_ SELF']; ?>" method="P OST">< br /> <tr>
<td>Usern ame: <BR> (only A-Z, 0-9 and _ Allowed)<BR& gt;</td>< br /> <td><i nput type="tex t" id ="usernam e" name="use rname" value="& quot; maxlength=&quo t;30"> <BR></ td>
</tr>
<tr>
<td>Passw ord:</td>
<td><i nput type="pas sword" id="passw ord" name="pas sword" value="& quot; maxlength=&quo t;30"> <BR> (minimum 6

characters)< /td>
</tr>
<tr>
<td>Verif y Pass:</td> ;
<td><i nput type="pas sword" id="verif y_password&quo t; name="ver ify_password&q uot; value="& quot; maxlength=&quo t;30"> <BR>

</td>
</tr>
<tr>
<td>Email :</td>
<td><i nput type="tex t" id="email " name="ema il" value="& quot; size="30 "><b r></td> ;
</tr>
<tr>
<td>Click to Complete Signup:</td& gt;
<td><i nput type="sub mit" id="submi t" name="sub mit" value="su bmit"> </td>
</tr>
</form>< br /> </table>
<?
} //end not logged in
} //end submit not pressed
?>




It me it me

    Viewed: 10,539 Times | Reply to This | To top
  This user is offline  bs0d
  Subject: "re: Need some help" Posted: @ 7:46 pm on Feb 21 2008    

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

Delete line 21




-bs0d | AllSyntax.com

    Viewed: 10,522 Times | Reply to This | To top
  This user is offline  solphate
  Subject: "re: Need some help" Posted: @ 8:32 pm on Feb 21 2008    
Member #: 581
Rank: User - (24)
Since: 02/18/08
Posts: 24

now what about the login stuff above




It me it me

    Viewed: 10,519 Times | Reply to This | To top
  This user is offline  solphate
  Subject: "re: Need some help" Posted: @ 8:36 pm on Feb 21 2008    
Member #: 581
Rank: User - (24)
Since: 02/18/08
Posts: 24

Ok k i deleted line 21 now when i click the register link it just te register page is just blank




It me it me

    Viewed: 10,517 Times | Reply to This | To top
  This user is offline  Genius
  Subject: "re: Need some help" Posted: @ 2:50 am on Feb 26 2008    

Member #: 582
Rank: User - (77)
Since: 02/18/08
Posts: 76
From: kmmk

I had the same problem.
Line 12:

Code:

if(isset($HTTP _POST_VARS['su bmit']))



Change it to:

Code:
if(isset($_POS T['submit']))




    Viewed: 10,425 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-2017; All rights lefted, all lefts righted.
Privacy Policy  |  Internet Rank