Go Back   Novahq.net Forum > Computers > Web design and Programming
FAQ Community Calendar Today's Posts Search

Web design and Programming Discuss website creation and other programming topics.

Reply
 
Thread Tools Search this Thread Display Modes
  #21  
Old 04-15-2005, 11:41 PM
DevilDog#1 is offline DevilDog#1

Join Date: Jul 2002
Posts: 7,040

Getting


You do not have permission to access this page. Please login Below.
Username:
Password:
Submit -- Reset



You keep referring to code above... you talking about P's code or Elite's?
__________________








Quote:
If I don't do that doesn't mean I can't - DD#1
Reply With Quote
  #22  
Old 04-15-2005, 11:41 PM
KoBrA is offline KoBrA
Registered User

Join Date: Jul 2004
Posts: 25

Send a message via AIM to KoBrA
read the rest of the post
__________________
Reply With Quote
  #23  
Old 04-15-2005, 11:45 PM
DevilDog#1 is offline DevilDog#1

Join Date: Jul 2002
Posts: 7,040

Can I see your code please?
__________________








Quote:
If I don't do that doesn't mean I can't - DD#1
Reply With Quote
  #24  
Old 04-15-2005, 11:48 PM
KoBrA is offline KoBrA
Registered User

Join Date: Jul 2004
Posts: 25

Send a message via AIM to KoBrA
mine? ... its the same as he gave me

Code:
<?
function login_form() {?>

	<form method="post" action="<?Echo($_SERVER['PHP_SELF']);?>">
	Username: <input type="text" name="username" /><br />
	Password: <input type="password" name="password" /><br />
	<input type="hidden" name="login" value="true" />
	<input type="submit" name="login" value=" Login " /> <input type="reset" value=" Reset " />
	</form>

<?}

If($_POST['login']) {

	$username=mysql_real_escape_string($_POST['username']);
	$password=mysql_real_escape_string($_POST['password']);
	
	$query=mysql_query("SELECT * FROM users WHERE username='".$username."' AND password='".$password."' LIMIT 1");
	
	If(mysql_num_rows($query) > 0) {
		setcookie("loggedin","true",time+36000); //1 day
		sleep(1);
	}
	mysql_free_result($query);
	
	header("Location: ".$_SERVER['PHP_SELF']);
	exit;

}



If($_COOKIE['loggedin']!="true") {

	Echo(" You do not have permission to access this page. Please login Below. ");
	login_form(); // print the login form
	exit;

}?>
__________________
Reply With Quote
  #25  
Old 04-16-2005, 12:01 AM
DevilDog#1 is offline DevilDog#1

Join Date: Jul 2002
Posts: 7,040

Try

PHP Code:

<?php
function login_form() {?>

    <form method="post" action="<?php Echo($_SERVER['PHP_SELF']);?>">
    Username: <input type="text" name="username" /><br />
    Password: <input type="password" name="password" /><br />
    <input type="hidden" name="login" value="true" />
    <input type="submit" name="login" value=" Login " /> <input type="reset" value=" Reset " />
    </form>

<?php }

If(
$_POST['login']) {

     
$username=mysql_real_escape_string($_POST['username']);
     
$password=mysql_real_escape_string($_POST['password']);
    
    
$query=mysql_query("SELECT * FROM users WHERE username='".$username."' AND password='".$password."' LIMIT 1");
    
    If(
mysql_num_rows($query) > 0) {
        
setcookie("loggedin","true",time+36000); //1 day
        
sleep(1);
    }
    
mysql_free_result($query);
    
    
header("Location: ".$_SERVER['PHP_SELF']);
    exit;
}

If(
$_COOKIE['loggedin']!="true") {

    Echo(
" You do not have permission to access this page. Please login Below. ");
    
login_form(); // print the login form
    
exit;
}
?>
__________________








Quote:
If I don't do that doesn't mean I can't - DD#1

Last edited by DevilDog#1; 04-16-2005 at 12:09 AM.
Reply With Quote
  #26  
Old 04-16-2005, 12:10 AM
KoBrA is offline KoBrA
Registered User

Join Date: Jul 2004
Posts: 25

Send a message via AIM to KoBrA
got an error now .... the login boxes don't show
__________________
Reply With Quote
  #27  
Old 04-16-2005, 12:17 AM
DevilDog#1 is offline DevilDog#1

Join Date: Jul 2002
Posts: 7,040

Interesting ... Try now

PHP Code:
<?
function login_form() {?>

    <form method="post" action="<? Echo($_SERVER['PHP_SELF']);?>">
    Username: <input type="text" name="username" /><br />
    Password: <input type="password" name="password" /><br />
    <input type="hidden" name="login" value="true" />
    <input type="submit" name="login" value=" Login " /> <input type="reset" value=" Reset " />
    </form>

<? }

If(
$_POST['login']) {

     
$username=mysql_real_escape_string($_POST['username']);
     
$password=mysql_real_escape_string($_POST['password']);
    
    
$query=mysql_query("SELECT * FROM users WHERE username='".$username."' AND password='".$password."' LIMIT 1");
    
    If(
mysql_num_rows($query) > 0) {
        
setcookie("loggedin","true",time+36000); //1 day
        
sleep(1);
    }
    
mysql_free_result($query);
    
    
header("Location: ".$_SERVER['PHP_SELF']);
    exit;
}

If(
$_COOKIE['loggedin']!="true") {

    Echo(
" You do not have permission to access this page. Please login Below. ");
    
login_form(); // print the login form
    
exit;
}
?>
__________________








Quote:
If I don't do that doesn't mean I can't - DD#1
Reply With Quote
  #28  
Old 04-16-2005, 12:24 AM
KoBrA is offline KoBrA
Registered User

Join Date: Jul 2004
Posts: 25

Send a message via AIM to KoBrA
when i try to login with the user and pass that i registered and it said was success full i get this

Code:
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home2/kobra/public_html/unitedalliance/login.php on line 22

Warning: mysql_free_result(): supplied argument is not a valid MySQL result resource in /home2/kobra/public_html/unitedalliance/login.php on line 26

Warning: Cannot modify header information - headers already sent by (output started at /home2/kobra/public_html/unitedalliance/login.php:22) in /home2/kobra/public_html/unitedalliance/login.php on line 28
__________________
Reply With Quote
  #29  
Old 04-16-2005, 12:30 AM
DevilDog#1 is offline DevilDog#1

Join Date: Jul 2002
Posts: 7,040

Is your DB working ok?

Run this code ... you'll know if your DB is working. Save it as "mysql_connect.php"

PHP Code:
<html>

<head>
</head>

<body>

<?php


if ($dbc = @mysql_connect('localhost''username''password') ) {

    print 
'<p>Successfully connected to MySQL.</p>';

    
mysql_close();

} else {

    die(
'<p>Could not connect to MySQL because: <b>'mysql_error().'</b></p>');

}

?>

</body>
</html>
__________________








Quote:
If I don't do that doesn't mean I can't - DD#1

Last edited by DevilDog#1; 04-16-2005 at 12:56 PM.
Reply With Quote
  #30  
Old 04-16-2005, 12:31 AM
KoBrA is offline KoBrA
Registered User

Join Date: Jul 2004
Posts: 25

Send a message via AIM to KoBrA
should i can run forums off it .. the user has all privlages ... umm
__________________
Reply With Quote
  #31  
Old 04-16-2005, 12:33 AM
DevilDog#1 is offline DevilDog#1

Join Date: Jul 2002
Posts: 7,040

and the forum is up? and you do posts and stuff?
__________________








Quote:
If I don't do that doesn't mean I can't - DD#1
Reply With Quote
  #32  
Old 04-16-2005, 02:31 AM
KoBrA is offline KoBrA
Registered User

Join Date: Jul 2004
Posts: 25

Send a message via AIM to KoBrA
idk i just cleared everythign .. and made new a new database for this
__________________
Reply With Quote
  #33  
Old 04-16-2005, 09:16 AM
JonM is offline JonM
Registered User

Join Date: Jun 2004
Posts: 2,156

u know what guys...i'm liking ur code and all, but how can you tell if there logged in? all it does is check if they aren't logged in if i'm readding it correctly...

PHP Code:
<? 
function login_form() {?> 

    <form method="post" action="<? Echo($_SERVER['PHP_SELF']);?>"> 
    Username: <input type="text" name="username" /><br /> 
    Password: <input type="password" name="password" /><br /> 
    <input type="hidden" name="login" value="true" /> 
    <input type="submit" name="login" value=" Login " /> <input type="reset" value=" Reset " /> 
    </form> 

<? 

If(
$_POST['login']) { 

      
$username=mysql_real_escape_string($_POST['userna
me'
]); 
      
$password=mysql_real_escape_string($_POST['passwo
rd'
]); 
     
    
$query=mysql_query("SELECT * FROM users WHERE username='".$username."' AND password='".$password."' LIMIT 1"); 
     
    If(
mysql_num_rows($query) > 0) { 
        
setcookie("loggedin","true",time+36000); //1 day 
        
sleep(1); 
    } 
    
mysql_free_result($query); 
     
    
header("Location: ".$_SERVER['PHP_SELF']); 
    exit; 


If(
$_COOKIE['loggedin']!="true") { 

    Echo(
" You do not have permission to access this page. Please login Below. "); 
    
login_form(); // print the login form 
    
exit; 
}
?>

c i would change the cookie to this to:
PHP Code:
setcookie("loggedin","".$username."",time+36000); //1 day 
then i would replace this part
PHP Code:
If($_COOKIE['loggedin']!="true") { 

    Echo(
" You do not have permission to access this page. Please login Below. "); 
    
login_form(); // print the login form 
    
exit; 
}
?> 
to:
PHP Code:

//replace with if(!$_COOKIE['loggedin'] || $_COOKIE['loggedin']==""){
echo'This is a restricted page to members only, you may login or <a href="register.php">Register</a>';
}else{
/*the users got the cookie and is loggedin*/
$nick=$_COOKIE['loggedin'];
echo
'Welcome back <b>'.$nick.'</b>!  You may now access restricted parts of the site!';

also u may just need to fix some db issues, like your connect or something for the error.
Reply With Quote
  #34  
Old 04-16-2005, 10:44 AM
Stu is offline Stu
Resident Member

Join Date: Aug 2003
Posts: 3,319

Your MySQL server might be currupt. I know when i was using Lycos i had alot of trouble for nothing
Reply With Quote
  #35  
Old 04-16-2005, 12:31 PM
DevilDog#1 is offline DevilDog#1

Join Date: Jul 2002
Posts: 7,040

Just get EASYPHP and play locally. Then get Apache and PHP individually and play with that and then when you feel you're expert get a webspace.
__________________








Quote:
If I don't do that doesn't mean I can't - DD#1
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Php Nuke General Nuisance Web design and Programming 5 11-21-2004 08:43 PM
PHP Nuke :| NaughtyPerry Web design and Programming 2 11-08-2004 04:15 PM
How Do U Use Php Nuke? Wilson1990 Web design and Programming 11 08-05-2004 08:29 PM
PHP NUKE SKINS XenoMorpH Web design and Programming 7 04-06-2003 06:34 AM
PHP Nuke 6.0 Help hodog Web design and Programming 3 10-17-2002 04:32 AM


All times are GMT -5. The time now is 03:56 AM.




Powered by vBulletin®