Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Old 09-19-2007, 01:38 PM Basic login issue
afridy's Avatar
Extreme Talker

Posts: 196
Trades: 0
Hai, i am new to php and requir your support.

i am dealing with my mysql db.
the user logs on and the login is processed by logon.php.
then the user adds record to the db. the add record is processed by addrec.php.

my problem is, addrec.php is requesting a connection again to add the record. but the user has already provided his logon credentials at the first logon. so how do i main tain his user name and passord through all the scripts ?

please.
afridy is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 09-19-2007, 01:42 PM Re: Basic login issue
dansgalaxy's Avatar
Defies a Status

Posts: 6,521
Name: Dan
Location: Swindon
Trades: 0
This is a simple thing, which can be handled in multiple ways and even combing them

you can (should) set a session on a successful login.

i have a login script (orginally written by gaby solomon) which was written so i could simple include login.php on pages i want password protected, and then it checks if a session exists, if it does and is valid shows page, if not shows login.

you can also set cookies but they are advised against.

have a look for session/login on php.net and google.

i can help more later i have to go out now :P

TP apprieciated
__________________
Discounted Web Hosting With XDnet!
>> Get 25% of hosting~ Promo: Webmaster-talk <<

Please login or register to view this content. Registration is FREE
dansgalaxy is offline
Reply With Quote
View Public Profile Visit dansgalaxy's homepage!
 
Old 09-19-2007, 01:56 PM Re: Basic login issue
NullPointer's Avatar
Will Code for Food

Posts: 2,815
Name: Matt
Location: Irvine, CA
Trades: 0
You can use session variables just like any other super global. When you want to create a new session or open a session that already exists use the start_session() command. Then you can begin setting session variables by doing the following $_SESSION['variable'] = $yourvariable. When you want to delete a session use the session_destroy() command.
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
NullPointer is online now
Reply With Quote
View Public Profile Visit NullPointer's homepage!
 
Old 09-19-2007, 02:25 PM Re: Basic login issue
afridy's Avatar
Extreme Talker

Posts: 196
Trades: 0
Thanks NullPointer and Dansgalaxi for the solutions. really appriciated.
let me try them.
afridy is offline
Reply With Quote
View Public Profile
 
Old 09-19-2007, 03:24 PM Re: Basic login issue
dansgalaxy's Avatar
Defies a Status

Posts: 6,521
Name: Dan
Location: Swindon
Trades: 0
Sorry i couldnt exmplain further about sessions, i was being moaned at for not going fast enough

if you need any more help i can try and lend a hand
__________________
Discounted Web Hosting With XDnet!
>> Get 25% of hosting~ Promo: Webmaster-talk <<

Please login or register to view this content. Registration is FREE
dansgalaxy is offline
Reply With Quote
View Public Profile Visit dansgalaxy's homepage!
 
Old 09-19-2007, 07:13 PM Re: Basic login issue
afridy's Avatar
Extreme Talker

Posts: 196
Trades: 0
Thank You very much guys.
yah, session_start() worked for me.
i put the following code in my login script.
Code:
session_start();
$_SESSION['username']=$name;
$_SESSION['password']=$pass;
then when i requir the thease information in addrecord.php file,
i put the folowing code
Code:
session_start();
$name=$_SESSION['username'];
$pass=$_SESSION['password'];
hope my code is correct. because it worked.

let me rate your helpfull posts.
afridy is offline
Reply With Quote
View Public Profile
 
Old 09-19-2007, 07:32 PM Re: Basic login issue
dansgalaxy's Avatar
Defies a Status

Posts: 6,521
Name: Dan
Location: Swindon
Trades: 0
you should really get some security in there tho, as someone know knows how, or just know php enough knows all sorts of bits for hacking, hence you should secure scripts as much as possible.. and ALWAYS use mysql_real_escape_string() on inputs which will go anywhere near your mysql_query() 's Lol
__________________
Discounted Web Hosting With XDnet!
>> Get 25% of hosting~ Promo: Webmaster-talk <<

Please login or register to view this content. Registration is FREE
dansgalaxy is offline
Reply With Quote
View Public Profile Visit dansgalaxy's homepage!
 
Old 09-19-2007, 10:06 PM Re: Basic login issue
NullPointer's Avatar
Will Code for Food

Posts: 2,815
Name: Matt
Location: Irvine, CA
Trades: 0
Also make sure you apply encryption before sending a password to the database. You should apply at least an sha1 as soon as you get the password from post ($password = sha1($_POST['password']);
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
NullPointer is online now
Reply With Quote
View Public Profile Visit NullPointer's homepage!
 
Old 09-20-2007, 08:05 AM Re: Basic login issue
dansgalaxy's Avatar
Defies a Status

Posts: 6,521
Name: Dan
Location: Swindon
Trades: 0
I forgot to mention that also. it mangles it all up and means a) you cant see a users password (but you can just write it in that admin has access to all anyway so u wont need it ) and also if someone hacks the db or even if your host gets nosy ...
__________________
Discounted Web Hosting With XDnet!
>> Get 25% of hosting~ Promo: Webmaster-talk <<

Please login or register to view this content. Registration is FREE
dansgalaxy is offline
Reply With Quote
View Public Profile Visit dansgalaxy's homepage!
 
Reply     « Reply to Basic login issue
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.36389 seconds with 12 queries