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
PHP Cookie Help Needed
Old 06-11-2006, 05:27 PM PHP Cookie Help Needed
UKG
Junior Talker

Posts: 3
Trades: 0
I need this script to connect to the database etc which all works perfectly then check if the user is logged in via cookie check... if they aren't i need to to redirect to re_login.php and if they are then display the page that includes this script...

Can it be done and am i on the right lines??


Code so far for auth.php

PHP Code:
<?php
$userid   
$HTTP_COOKIE_VARS['bbuserid']; 
$password $HTTP_COOKIE_VARS['bbpassword']; 
$vbhost   "localhost"
$vbuser   "user"
$vbpass   "pass"
$vbname   "name"
$vb=mysql_connect("$vbhost","$vbuser","$vbpass"); 
mysql_select_db($vbname,$vb) or die ("Forum Database Connectivity Error"); 
$vbsql=mysql_query("select * from user where userid = '$userid'"); 
$vbinfo=@mysql_fetch_array($vbsql); 
$username=$vbinfo[username]; 
 
if (!
$username) {}{ 
header('location: re_login.php');
} elseif (
$username) {
?>
UKG is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 06-12-2006, 01:13 PM Re: PHP Cookie Help Needed
Christopher's Avatar
Iced Cap

Latest Blog Post:
Cross-domain AJAX with JSONP
Posts: 3,110
Location: Toronto, Ontario
Trades: 0
Yes, it seems okay so far. Though in that code snippet I don't see where you are verifying the users password.

The reason the redirect may not be working is because the Location header needs an entire URL, not just a path (relative paths work only for some clients). For example:
Code:
header('Location: http://mydomain.com/re_login.php');
And you have to make sure the header is sent before any other headers. Headers are sent when output is sent (HTML, or even something as small as a newline ), or cookies are set etc. Sometimes it is easier to just output an HTML page that auto-redirects the user.
__________________

Please login or register to view this content. Registration is FREE
- Latest Articles:
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

Christopher is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to PHP Cookie Help Needed
 

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.09711 seconds with 12 queries