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 is not forwarding user to new page
Old 08-30-2010, 10:30 AM PHP is not forwarding user to new page
leebert45's Avatar
Novice Talker

Posts: 14
Name: Lee Wentzel
Location: Michigan, USA
Trades: 0
Here is my code... I am testing a password and assigning a cookie accordingly. After I've done so, I want the validation page to forward to user to the members page.

Code:
<?php
   $test = $_POST['Password1'];
   if ($test == 'BowWow') {
      $_COOKIE['Level'] = 'One';
   }
   if ($test == 'Testing') {
      $_COOKIE['Level'] = 'Two';
   }
   if ($test == 'GrandPooBah') {
      $_COOKIE['Level'] = 'Three';
   }

   header("Location:" . 'members.php');
?>
I've tested the code and verified that it is sending the password along properly. I've also verified that the Level cookie is being set to One, Two or Three. It just isn't forwarding the person to the members.php page. Any help would be appreciated. Thanks.

Leebert45
__________________
It's never "just a game" when you're winning.
~ George Carlin ~
leebert45 is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 08-30-2010, 10:42 AM Re: PHP is not forwarding user to new page
leebert45's Avatar
Novice Talker

Posts: 14
Name: Lee Wentzel
Location: Michigan, USA
Trades: 0
Ok, so it looks like that previous code is working. The code on the members.php page which looks for the cookie doesn't seem to work. Here is what I have:

Code:
<?php
  $test = $_COOKIE['Level'];
  if ($test == '') {
     header("Location:" . 'login.htm');
  }
  echo $test;
?>
__________________
It's never "just a game" when you're winning.
~ George Carlin ~
leebert45 is offline
Reply With Quote
View Public Profile
 
Old 08-30-2010, 11:04 AM Re: PHP is not forwarding user to new page
leebert45's Avatar
Novice Talker

Posts: 14
Name: Lee Wentzel
Location: Michigan, USA
Trades: 0
Fixed things sort of. Instead of having a validation.php file which set the cookie and verified the passwords, I am sending the data right to the members page. That way it can validate the password, and give access to member without the need for cookies.
__________________
It's never "just a game" when you're winning.
~ George Carlin ~
leebert45 is offline
Reply With Quote
View Public Profile
 
Old 08-30-2010, 01:00 PM Re: PHP is not forwarding user to new page
Novice Talker

Posts: 5
Trades: 0
header("location: blaat.php");

should work, make sure you add a exit(); behind it so it does not execute any code.
hmosselaer is offline
Reply With Quote
View Public Profile
 
Old 08-31-2010, 05:49 AM Re: PHP is not forwarding user to new page
Extreme Talker

Posts: 149
Trades: 0
Common pitfalls:

Cookies will not become visible until the next loading of a page that the cookie should be visible for. To test if a cookie was successfully set, check for the cookie on a next loading page before the cookie expires. Expire time is set via the expire parameter. A nice way to debug the existence of cookies is by simply calling print_r($_COOKIE);.

Source: http://php.net/manual/en/function.setcookie.php
__________________
Free
Please login or register to view this content. Registration is FREE

Visit our
Please login or register to view this content. Registration is FREE
and
Please login or register to view this content. Registration is FREE
mimamo is offline
Reply With Quote
View Public Profile
 
Old 08-31-2010, 05:56 AM Re: PHP is not forwarding user to new page
lynxus's Avatar
Awesomeo-Maximo

Posts: 1,618
Location: UK
Trades: 1
Also dont use cookies if you dont want people "cheating" on your site.. They can be edited to say whatever.
__________________

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


lynxus is offline
Reply With Quote
View Public Profile Visit lynxus's homepage!
 
Old 08-31-2010, 01:13 PM Re: PHP is not forwarding user to new page
Average Talker

Posts: 19
Name: Colton
Location: NC, USA
Trades: 0
Quote:
Originally Posted by lynxus View Post
Also dont use cookies if you dont want people "cheating" on your site.. They can be edited to say whatever.
Agreed. It's much safer to use a $_SESSION when you're dealing with something like this.
http://php.net/session
Colton is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to PHP is not forwarding user to new page
 

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