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
Need help please! Pretty confused!
Old 08-13-2009, 11:45 AM Need help please! Pretty confused!
keva's Avatar
Novice Talker

Posts: 14
Name: Kevin
Trades: 0
Hi guys.
I have a little problem on my webpage. It's about HTML and PHP. Itr's about session check. I tried to make a member area. And can check if a user is already logged in and don't have to re-log in again if they want to enter in the member area. So i embeded a php code in HTML. I put it before the <html> tag witch is in the top. But when I tried it the it won't work. Could soemone please help me. And when I upload it as login.php then an error happen. I can't figure out where is thge problem. Please guys help me.
Thanks for reading my thread.
Sincerly
Keva
keva is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 08-13-2009, 12:23 PM Re: Need help please! Pretty confused!
lizciz's Avatar
Super Spam Talker

Posts: 807
Name: Mattias Nordahl
Location: Sweden
Trades: 0
You're gonna have to tell us more than that. What happens when you try to view the page and what error messages are you getting? Please also post the faulty code so we can see it.
__________________
Your answers will only be as good as your question. Formulate it well and give all the necessary information.
lizciz is offline
Reply With Quote
View Public Profile Visit lizciz's homepage!
 
Old 08-13-2009, 02:28 PM Re: Need help please! Pretty confused!
orionoreo's Avatar
Ultra Talker

Posts: 335
Name: Jerry
Trades: 0
really? you're going to ask us help without showing us the code nor the errors?
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
orionoreo is offline
Reply With Quote
View Public Profile
 
Old 08-13-2009, 06:01 PM Re: Need help please! Pretty confused!
keva's Avatar
Novice Talker

Posts: 14
Name: Kevin
Trades: 0
Sorry guys. Here is a part of the header.
------------------------
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<?php
session_start ();
//this code checks to see if the user is logged in, if yes allowed to continue
//If not redirected to the login page
if (@$login |= "yes")
{
header ("location: http://mywebsite/login.html");
exit();
}
session_destroy();
?>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
<meta name="author" content="KEVA">
<title>Untitled</title>
....
----------------------------------
What I want to do is sign in or sign up before you enter to the index. So when I type http://mywebsite/index.html, even if i'm not logged in then it goes to the member area. There no error.
If you guys have any suggestions or help, please reply.
Keva
keva is offline
Reply With Quote
View Public Profile
 
Old 08-13-2009, 07:57 PM Re: Need help please! Pretty confused!
lizciz's Avatar
Super Spam Talker

Posts: 807
Name: Mattias Nordahl
Location: Sweden
Trades: 0
Ok... That is not going to work. First off, you need to call session_start() before ANY output, so the <?php tag should go before the doctype. And be careful not to include any empty rows or spaces before the tag.

Secondly, $login will have no value in your code so there is no point of comparing it to anything. You should get the value from the session which you would normally store upon successful login. For example in $_SESSION['loggedIn'].

And third, I've never seen a |= operator before and can only assume it is suppose to be !=

(Forth, the @ will make sure any error that occur is ignored instead of being printed, but in a simple comparison like this there will be no errors and so the @ is not needed.)

Which gives us this:

PHP Code:
<?php
session_start 
();
//this code checks to see if the user is logged in, if yes allowed to continue
//If not redirected to the login page
$login $_SESSION['loggedIn']; // or what ever name you choose for the variable
if ($login != "yes")
{
header ("location: http://mywebsite/login.html");
exit();
}
session_destroy();
?>
<!doctype ...>
__________________
Your answers will only be as good as your question. Formulate it well and give all the necessary information.
lizciz is offline
Reply With Quote
View Public Profile Visit lizciz's homepage!
 
Old 08-14-2009, 10:19 AM Re: Need help please! Pretty confused!
keva's Avatar
Novice Talker

Posts: 14
Name: Kevin
Trades: 0
Thank you so much. I will do that. (I'm not on mmy computer that's why I said I will).
Keva
keva is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Need help please! Pretty confused!
 

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