Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Old 01-18-2003, 06:16 PM   #1 (permalink)
trevor
Code Monkey
 
Join Date: Jan 2003
Location: Canada
Posts: 91
trevor is on a distinguished road
last problem, I promise

PHP Code:
<?
include("connect.php");

session_start();
session_register(username,password);

$result=mysql_query("select * from users where username='$username' and password='$password'");
$num=mysql_num_rows($result);
if(
$num 1){
  
header("location: failed2.php");
}
?>
It always sends you to failed2.php. login.php likes my password but main.php doesn't. What I dont get is how the $username and $password variable can be passed from one .php file to another.

but anyway that code it straight from sde so it should work.

thanks again,

Trevor
trevor is offline   Reply With Quote
Old 01-18-2003, 06:21 PM   #2 (permalink)
anon
Guest
 
Posts: n/a
the best way (well I suck at PHP but the best way I know ) is to put it in the URL like

main.php?username="f"&password="g"
  Reply With Quote
Old 01-18-2003, 06:24 PM   #3 (permalink)
Ilya020
Techno Rat
 
Ilya020's Avatar
 
Join Date: Jan 2003
Location: San Diego
Posts: 559
Ilya020 is on a distinguished road
Send a message via AIM to Ilya020
Quote:
Originally posted by Vlad902
the best way (well I suck at PHP but the best way I know ) is to put it in the URL like

main.php?username="f"&password="g"
huh? dont get the last line...


Ilya
__________________
> SELECT * FROM users WHERE clue > 0
0 rows returned
Ilya020 is offline   Reply With Quote
Old 01-18-2003, 06:25 PM   #4 (permalink)
trevor
Code Monkey
 
Join Date: Jan 2003
Location: Canada
Posts: 91
trevor is on a distinguished road
isn't that a bit of a security hole?

so like

header("location: main.php?username=$username&password=$password");
into login.php
trevor is offline   Reply With Quote
Old 01-18-2003, 06:27 PM   #5 (permalink)
Ilya020
Techno Rat
 
Ilya020's Avatar
 
Join Date: Jan 2003
Location: San Diego
Posts: 559
Ilya020 is on a distinguished road
Send a message via AIM to Ilya020
Quote:
Originally posted by ilya020


huh? dont get the last line...


Ilya
I am an IDIOT...get it now

Ilya
__________________
> SELECT * FROM users WHERE clue > 0
0 rows returned
Ilya020 is offline   Reply With Quote
Old 01-18-2003, 06:27 PM   #6 (permalink)
anon
Guest
 
Posts: n/a
Quote:
Originally posted by trevor
isn't that a bit of a security hole?
True, not if you use encryption though. But truly I don't know any other way
  Reply With Quote
Old 01-18-2003, 06:28 PM   #7 (permalink)
anon
Guest
 
Posts: n/a
Quote:
Originally posted by trevor
isn't that a bit of a security hole?

so like

header("location: main.php?username=$username&password=$password");
into login.php
You could use one of the many default encryption functions that comes with PHP, or you could just find another way, but truly I don't know how to do it another way :o
  Reply With Quote
Old 01-18-2003, 06:30 PM   #8 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,444
sde is on a distinguished road
haah .. yes, you don't use the 'GET' method with passwords.

your php server must support sessions. i think i made a mistake by registering 2 variables in 1 line of session_register.

replacing the 2 session_lines with this:
PHP Code:
session_start(); 
session_register(username);
session_register(password); 
if you have weird trouble, like it fails everytime, .. close the browser and re-open it. the first time you login it should be ok no matter what. then if sessions are working, you will be able to navigate through your site with the code you have above on every page.
sde is offline   Reply With Quote
Old 01-18-2003, 06:32 PM   #9 (permalink)
anon
Guest
 
Posts: n/a
sde, damn, guess no more exploiting his site . But alot of sites do it (Yahoo!, MSN) and they use encryption and they can get away with it...
  Reply With Quote
Old 01-18-2003, 06:32 PM   #10 (permalink)
trevor
Code Monkey
 
Join Date: Jan 2003
Location: Canada
Posts: 91
trevor is on a distinguished road
hey, whatever works.

I'll deal with the encryption stuff some other time.

thanks again,

Trevor
trevor is offline   Reply With Quote
Old 01-18-2003, 06:34 PM   #11 (permalink)
trevor
Code Monkey
 
Join Date: Jan 2003
Location: Canada
Posts: 91
trevor is on a distinguished road
Quote:
Originally posted by sde
haah .. yes, you don't use the 'GET' method with passwords.

your php server must support sessions. i think i made a mistake by registering 2 variables in 1 line of session_register.

replacing the 2 session_lines with this:
PHP Code:
session_start(); 
session_register(username);
session_register(password); 
if you have weird trouble, like it fails everytime, .. close the browser and re-open it. the first time you login it should be ok no matter what. then if sessions are working, you will be able to navigate through your site with the code you have above on every page.
woah wait. Its working. what do you mean by not using the GET method with passwords?
trevor is offline   Reply With Quote
Old 01-18-2003, 06:34 PM   #12 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,444
sde is on a distinguished road
passwords defined in the url isn't really a security problem within the site itself. it is poor construction purely because someone looking over your shoulder can see your password. and most likely this website isn't the only site you use that password.

also, if you do it that way, you must use the url encode function within php to assure your password ( including special characters ) is able to be interprited within the browser.
sde is offline   Reply With Quote
Old 01-18-2003, 06:36 PM   #13 (permalink)
anon
Guest
 
Posts: n/a
Quote:
Originally posted by trevor


woah wait. Its working. what do you mean by not using the GET method with passwords?
He means it's not safe because you can see the password if it is unencrypted in the URL...
  Reply With Quote
Old 01-18-2003, 06:37 PM   #14 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,444
sde is on a distinguished road
passing variables through the url is using the 'GET' method. if you make a form like this: <form method=GET action=login.php> , you will notice that all the variables in your form will show up in the url.

when you use the GET method, your variables are limited to something like 255 characters. if you use the POST method, it is whatever is defined by the server. ( usually several MB )
sde is offline   Reply With Quote
Old 01-18-2003, 06:40 PM   #15 (permalink)
anon
Guest
 
Posts: n/a
sde, only probably I have is whenever I use post and enter something lets say I have a textbox called blah and I do echo $blah, it doesn't return anything, so is it me, or Apache? (I am asking this so I can give trevor some code to use ) I am sure I just have to do something but to give trevor some working code I need to know how


EDIT: Although sde can probably give alot better code than me....
  Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

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
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Web Design Problem elusionsdesign HTML, XML, Javascript, AJAX 2 11-09-2003 07:01 PM
Help debugging a power problem Belisarius Lounge 0 10-25-2003 04:44 PM
structure problem Goshi Standard C, C++ 5 04-21-2003 12:19 AM
This is a windows/C problem UnderWing Standard C, C++ 6 03-28-2003 06:17 AM
PHP / JS problem bdl HTML, XML, Javascript, AJAX 2 03-13-2003 08:53 AM


All times are GMT -8. The time now is 11:48 PM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting