|
 |
|
 |
01-18-2003, 08:38 PM
|
#1 (permalink)
|
|
Code Monkey
Join Date: Jan 2003
Location: Canada
Posts: 91
|
gotta be an easier way
than doing 'main.php?username=$username&password=$password'
Do I have to enter that into all of my navigation links?
|
|
|
01-18-2003, 09:14 PM
|
#2 (permalink)
|
|
Moderator
Join Date: May 2002
Location: us.ca
Posts: 4,444
|
that is what sessions are for .. it's really hard to read what i'm trying to tell you with all of illya's and vlads comments on your post, .. but look at the session stuff that i put in there.
sessions are what carry over variables automatically between pages. if you register "username" and "password" on every page from when the user logs in, .. you won't have to pass anything through the url.
|
|
|
01-18-2003, 09:53 PM
|
#4 (permalink)
|
|
Moderator
Join Date: May 2002
Location: us.ca
Posts: 4,444
|
i thought it worked when he submited the form .. and the problem was with passing the user/pass for everything inside the protected area.
if the original submission works, then he does not need the $_POST[] .. he needs to use sessions so the username and password variable stay valid for the entire time the user is on the site.
|
|
|
01-19-2003, 07:06 AM
|
#5 (permalink)
|
|
Guest
|
Quote:
Originally posted by sde
i thought it worked when he submited the form .. and the problem was with passing the user/pass for everything inside the protected area.
if the original submission works, then he does not need the $_POST[] .. he needs to use sessions so the username and password variable stay valid for the entire time the user is on the site.
|
Oh, sorry, I thought he was talking about when he submitted the form and using the get method in the form, but still, atleast now he knows about $_POST  But it worked when he submitted the form but he was using Get and as you said it's not secure... so now he can use this and not have to worry about that one....
|
|
|
|
01-19-2003, 07:27 AM
|
#6 (permalink)
|
|
Moderator
Join Date: May 2002
Location: us.ca
Posts: 4,444
|
from how i understood it, .. the problem was when he was trying to use the $Array[username] . i tried thie myself and could not get it to work.
in most php installations, you don' tneed to use $_POST[] ,although it could be good practice and it is more secure if you dont want people to be able to enter variables in the url.
user/pass like i said isn't that critical to be in the url for the site, as it is more of a security risk on the clients end when someone is looking over their shoulders.
|
|
|
01-19-2003, 07:29 AM
|
#7 (permalink)
|
|
Code Monkey
Join Date: Jan 2003
Location: Canada
Posts: 91
|
I still cant qite figure it out:
here is my code for main.php
PHP Code:
<?
include("connect.php");
session_start();
session_register("username");
session_register("password");
$password=$_GET['password'];
$username=$_GET['username'];
$result=mysql_query("select * from users where username='$username' and password='$password'");
$num=mysql_num_rows($result);
if($num < 1){
header("location: failed2.php");
}
?>
Now that part works fine. Just when I load the page profile.php which right now just simply lists username, email etc, i get the failed2.php.
my code for that part is:
PHP Code:
<?
include("connect.php");
session_start();
$result=mysql_query("select * from users where username='$username' and password='$password'");
$num=mysql_num_rows($result);
if($num < 1){
header("location: failed2.php");
}
?>
so the username and password should be registered so I can open them from any page right? what am I forgeting?
thanks,
Trevor
|
|
|
01-19-2003, 07:30 AM
|
#8 (permalink)
|
|
Guest
|
Quote:
Originally posted by sde
from how i understood it, .. the problem was when he was trying to use the $Array[username] . i tried thie myself and could not get it to work.
Yes that was the problem.
in most php installations, you don' tneed to use $_POST[] ,although it could be good practice and it is more secure if you dont want people to be able to enter variables in the url.
Actually that guide I gave you on installing Apache with PHP in the Linux forum, when I did it I have to use Post and it is the latest one out... (although it is Apache 1.3.27). But true it is more secure too.
user/pass like i said isn't that critical to be in the url for the site, as it is more of a security risk on the clients end when someone is looking over their shoulders.
|
And when you look back in the history as well, you can see lets say his sites name is lll.asd
well if you type in lll.asd you could see the old history, things like lll.asd/blah.php?asd=asd&lll=ddd
|
|
|
|
01-19-2003, 10:01 AM
|
#9 (permalink)
|
|
Code Monkey
Join Date: Jan 2003
Location: Canada
Posts: 91
|
is anyone here?
|
|
|
01-19-2003, 10:07 AM
|
#10 (permalink)
|
|
Centurion Nova Prime
Join Date: May 2002
Location: Oak Park, IL (USA)
Posts: 285
|
Trevor,
Try executing session_start() first on both pages (before the include). I remember reading somewhere that it has to be first on subsequent pages to work properly. I've never tried it, personally, but it's easy enough to try.
|
|
|
01-19-2003, 10:15 AM
|
#11 (permalink)
|
|
Code Monkey
Join Date: Jan 2003
Location: Canada
Posts: 91
|
nope, still not working,
thanks though
do I have to do:
PHP Code:
session_register("username");
session_register("password");
on every page?
|
|
|
01-19-2003, 02:24 PM
|
#12 (permalink)
|
|
Centurion Nova Prime
Join Date: May 2002
Location: Oak Park, IL (USA)
Posts: 285
|
Quote:
Originally posted by trevor
nope, still not working,
thanks though
do I have to do:
PHP Code:
session_register("username");
session_register("password");
on every page?
|
No. Just for giggles, try registering after setting the variables for the first time.
$password=$_GET['password'];
$username=$_GET['username'];
session_register("username");
session_register("password");
Also, session_register is supposed to return a boolean. I'd check that in an if to make sure it is working. If register_globals is off, session_register won't work according to info at php.net. The way your first example is written, it will still work even if session_register fails.
|
|
|
01-19-2003, 02:47 PM
|
#13 (permalink)
|
|
Moderator
Join Date: May 2002
Location: us.ca
Posts: 4,444
|
why are we using $_GET[] ???
also, i think you should have "session_start(); " at the top of each page before you register anything in the session.
|
|
|
01-19-2003, 03:25 PM
|
#14 (permalink)
|
|
Code Monkey
Join Date: Jan 2003
Location: Canada
Posts: 91
|
well I know it is registering the variable fine because I went to /tmp/sess_o4f1fc707...... and there was my username and password
now why aren't my other sites getting these variables.
sde, can you explain the idea of not having the $_GET please?
thanks all,
Trevor
|
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
Similar Threads
|
| Thread |
Thread Starter |
Forum |
Replies |
Last Post |
|
Easier answer?
|
Kernel_Killer |
HTML, XML, Javascript, AJAX |
4 |
02-26-2003 12:13 PM |
All times are GMT -8. The time now is 11:41 PM.
|
Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting
|
 |
|