Web Design Forums

PHP

Have questions about PHP? Ask them here and our experts will assist you before you know it! You can also find help in the documentation at PHP.net.

Problem with user log in code



Site of the Month Nominations
ENTER YOUR SITE NOW!

Reply
 
LinkBack Thread Tools
Old June 21 '09, 02:15 PM (#1)
DGS is offline
DGS
WDF Member
 
DGS's Avatar
 
Join Date: May 2009
Posts: 25
DGS is an unknown quantity at this point
Problem with user log in code

Hey everyone.

I found a script that I wanted to use that allows users to register to your website, access members-only pages, have their own profiles, ect...

But there seems to be a problem with the code that I have to put on the pages that I want to be members-only.

Here is the code:

Code:
<?php
$username = $_COOKIE['loggedin'];
if (!isset($_COOKIE['loggedin'])) die("You are not logged in, <a href="login.html">click here</a> to login.");
echo "You are logged in $username";
?>
Every time I try to run it, it tells me there's an error on this line:

Code:
if (!isset($_COOKIE['loggedin'])) die("You are not logged in, <a href="login.html">click here</a> to login.");
I do not know much of PHP, so I can't tell if anything is wrong.
It would be much appreciated if anyone could help me.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old June 21 '09, 02:42 PM (#2)
Danny[MLWA] is offline
WDF Regular
 
Danny[MLWA]'s Avatar
 
Join Date: June 2009
Location: Goldsboro, North Carolina, USA
Posts: 109
Danny[MLWA] is on a distinguished road
Code:
if (!isset($_COOKIE['loggedin'])) die("You are not logged in, <a href="login.html">click here</a> to login.");
Look closer...

Code:
die("You are not logged in, <a href="login.html">
You start the string with a quote.. then your're HTML stops the string with the quote... Not good... two ways to fix it...

1. Replace <a href="login.html"> with <a href='login.html'>
2. Or do it the real way.... <a href=\"login.html\">
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old June 21 '09, 03:01 PM (#3)
DGS is offline
DGS
WDF Member
 
DGS's Avatar
 
Join Date: May 2009
Posts: 25
DGS is an unknown quantity at this point
Oohhhh, how could I have missed that.

Thank you very much for your help!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old June 25 '09, 12:49 PM (#4)
Danny[MLWA] is offline
WDF Regular
 
Danny[MLWA]'s Avatar
 
Join Date: June 2009
Location: Goldsboro, North Carolina, USA
Posts: 109
Danny[MLWA] is on a distinguished road
I have a pretty mean login library for php if you're interested =). It uses the combination of the IP address, cookie, and php sessions which enables the "remember me" function from the same machine and browser (so no one can hijack the session's sent in unencrypted envornments he he).
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

  Web Design Forums » Programming Help » PHP

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Top 21 PHP Programming mistakes thexchord PHP 19 June 18 '10 02:20 PM
Tricky problem VegaLA Other Languages 2 April 22 '05 01:33 PM
User uploads code, or links to it bfsog PHP 2 November 28 '04 05:45 AM
Psuedo Code Please DanielGibbs PHP 5 June 12 '04 12:00 PM

 
User Infomation
Your Avatar

Site Of The Month

Ticket Cake
Ticket Cake

Ticket Cake is a drupal based event ticketing platform. It features that ability to browse events and share them.

Nominate Your Site Now!

Advertisement
WolfCMS.org

Latest Articles
- by RickM
- by bfsog

Advertisement

Partner Links



All times are GMT -4. The time now is 02:43 AM.


WebDesignForums.net is Copyright © 2010 RikeMedia.

SEO by vBSEO

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163