C and Cpp

 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me



Go Back   Tutorialized ForumsDesktop ProgrammingC and Cpp

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Tutorialized Forums Sponsor:
  #1  
Old June 25th, 2004, 05:31 PM
meat meat is offline
Contributing User
Tutorialized Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Location: San Diego
Posts: 158 meat New User: is a brand new recruit and a unknown entity at this point. 
Time spent in forums: 1 h 15 m 3 sec
Reputation Power: 0
Send a message via Skype to meat
Password Protection Question

Ok, I posted something on logins. But then I just thought of this, When someone goes on to a next page, how does the password protection carry on to that next page? Cookies? I must know, please post something someone... :
__________________
@robertoross
github.com/bobbytables

Reply With Quote
  #2  
Old June 26th, 2004, 01:51 AM
kurt kurt is offline
Contributing User
Tutorialized Novice (500 - 999 posts)
 
Join Date: Jan 2004
Posts: 506 kurt User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 m 48 sec
Reputation Power: 0
In PHP the best way is either using sessions, or using .htaccess for the directory.

Reply With Quote
  #3  
Old June 26th, 2004, 02:26 PM
meat meat is offline
Contributing User
Tutorialized Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Location: San Diego
Posts: 158 meat New User: is a brand new recruit and a unknown entity at this point. 
Time spent in forums: 1 h 15 m 3 sec
Reputation Power: 0
Send a message via Skype to meat
Wouldn't SQL have to search for the cookie first though? and if cookie exsist....

Reply With Quote
  #4  
Old June 26th, 2004, 02:26 PM
meat meat is offline
Contributing User
Tutorialized Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Location: San Diego
Posts: 158 meat New User: is a brand new recruit and a unknown entity at this point. 
Time spent in forums: 1 h 15 m 3 sec
Reputation Power: 0
Send a message via Skype to meat
I know sessions, but would I need SQL to search for the cookie on the users desktop? and if the cookie exsist, have
Code:
      {

        {if(isset$_cookie['username']); 
          print(". $_cookie['username'] . Loggedin"); }
       else { include(login.htm); }
                } 

Wouldn't that work? and just have SQL search for the cookie name in the db?

Reply With Quote
  #5  
Old July 2nd, 2004, 02:30 PM
Chippo Chippo is offline
Contributing User
Tutorialized Newbie (0 - 499 posts)
 
Join Date: Mar 2004
Location: Stockport, UK
Posts: 462 Chippo New User: is a brand new recruit and a unknown entity at this point. 
Time spent in forums: 23 h 32 m 47 sec
Reputation Power: 0
Send a message via MSN to Chippo
I use cookies with mine very easy to use but if you are using them in your scripts makesure u dont keep like important stuff in cookies, you could store an encrypted password eg md5(user_pass) and then on each page add a part to the script that checks the user and password held in the cookies to a user in the database if the check if the user and pass check the ones in the db

Reply With Quote
  #6  
Old July 5th, 2004, 07:30 PM
meat meat is offline
Contributing User
Tutorialized Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Location: San Diego
Posts: 158 meat New User: is a brand new recruit and a unknown entity at this point. 
Time spent in forums: 1 h 15 m 3 sec
Reputation Power: 0
Send a message via Skype to meat
yah, thats what I though I would do. Just having the cookie set is my problem. I know the setcookie() function in php. but its not working. And I know my host supports php. and I know the cookie doesn't exsist because I added this code in a test page.
Code:
 if(isset(" . $_COOKIE[user] . "));
        Print("Welcome back $_COOKIE[user]")

Reply With Quote
  #7  
Old August 6th, 2004, 05:52 AM
Instinct Instinct is offline
Contributing User
Tutorialized Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Posts: 4 Instinct New User: is a brand new recruit and a unknown entity at this point. 
Time spent in forums: < 1 sec
Reputation Power: 0
hey,
if you are just browsing the 'protected area' in one window i find that cookies are not needed. just sessions... it works for me, well at least i think it duz
(correct me if i'm wrong)

going back to wat kurt said about .htaccess, use it if ure protecting a specific folder rather than specific files.

*edit* sorry didnt realise it was a month old post
__________________
<!-- // Blah! // -->

Reply With Quote
  #8  
Old August 6th, 2004, 01:15 PM
Chippo Chippo is offline
Contributing User
Tutorialized Newbie (0 - 499 posts)
 
Join Date: Mar 2004
Location: Stockport, UK
Posts: 462 Chippo New User: is a brand new recruit and a unknown entity at this point. 
Time spent in forums: 23 h 32 m 47 sec
Reputation Power: 0
Send a message via MSN to Chippo
I have never actually tried using sessions with mine, have only tried cookies, I just find it alot easier lol dunno y

Reply With Quote
  #9  
Old August 6th, 2004, 01:36 PM
meat meat is offline
Contributing User
Tutorialized Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Location: San Diego
Posts: 158 meat New User: is a brand new recruit and a unknown entity at this point. 
Time spent in forums: 1 h 15 m 3 sec
Reputation Power: 0
Send a message via Skype to meat
yah, I know. Im with chippo

Reply With Quote
  #10  
Old August 6th, 2004, 04:52 PM
binime binime is offline
Contributing User
Tutorialized Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Location: England
Posts: 78 binime New User: is a brand new recruit and a unknown entity at this point. 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via MSN to binime Send a message via Yahoo to binime
i use both cookies and sessions, cookies to get informationt to see if they are already logged in and sessions to see if they are logged in when the user posts in shoutbox and comments etc works well together i use

Code:
if(isset($_COOKIE['user']) && isset($_COOKIE['pass']))
{
$_SESSION['username'] = $_COOKIE['user'];
$_SESSION['pass'] = $_COOKIE['pass'];
echo "Welcome back ".$_SESSION['username']."";
}
else
{
$FUNC->login();
}


just a simple code with login using a func class

Reply With Quote
  #11  
Old August 6th, 2004, 07:17 PM
meat meat is offline
Contributing User
Tutorialized Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Location: San Diego
Posts: 158 meat New User: is a brand new recruit and a unknown entity at this point. 
Time spent in forums: 1 h 15 m 3 sec
Reputation Power: 0
Send a message via Skype to meat
hmm, interestingh little code you got there.

Reply With Quote
  #12  
Old August 6th, 2004, 07:54 PM
Chippo Chippo is offline
Contributing User
Tutorialized Newbie (0 - 499 posts)
 
Join Date: Mar 2004
Location: Stockport, UK
Posts: 462 Chippo New User: is a brand new recruit and a unknown entity at this point. 
Time spent in forums: 23 h 32 m 47 sec
Reputation Power: 0
Send a message via MSN to Chippo
cud i be rude and ask you too post your login function so i could have a look

Reply With Quote
  #13  
Old August 6th, 2004, 09:09 PM
meat meat is offline
Contributing User
Tutorialized Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Location: San Diego
Posts: 158 meat New User: is a brand new recruit and a unknown entity at this point. 
Time spent in forums: 1 h 15 m 3 sec
Reputation Power: 0
Send a message via Skype to meat
I used sessions for this one, but it was experimetal, I am going to revert to cookies pretty soon cause this way isn't working some times.

Code:
<?

$conn = mysql_connect("localhost","meat","gameguy");
$sdb = mysql_select_db("meat");

$query = "SELECT * FROM admin_users WHERE user='$user' AND pass='$pass'";

$sql = mysql_query($query);

if(!$sql){

echo "<font color=red>Failed to login!! Please try again.</font>";
include("login.php");
exit;

}

else {

$time=date("h:ia d/j/y");

session_register('user');
$_SESSION['user'] = $user;

$query = "UPDATE admin_users SET admin_last='$time' WHERE user='$user' AND pass='$pass'";

$sql = mysql_query($query);

header("location: index.php");

}

?>


Thats the code to login, to check if the person is logged in. I did this:
Code:
<?

function sessioncheck(){
if(!session_is_registered('user')){
header("location: login.php");
}
}

session_start();
sessioncheck();

$user = $_SESSION['user'];

$conn = mysql_connect("localhost","meat","gameguy");
$sdb = mysql_select_db("meat");

$query = "SELECT * FROM admin_users WHERE user='$user'";

$sql = mysql_query($query);

$worked = mysql_fetch_array($sql);
$last = $worked[admin_last];

?>

The $last var is just the thing to find the last login for the user.

Reply With Quote
  #14  
Old August 11th, 2004, 09:17 PM
meat meat is offline
Contributing User
Tutorialized Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Location: San Diego
Posts: 158 meat New User: is a brand new recruit and a unknown entity at this point. 
Time spent in forums: 1 h 15 m 3 sec
Reputation Power: 0
Send a message via Skype to meat
Ok, new problem.

Ok, with all of the work ive done (haha) ive figured out my code doesnt work for logging in to a admin area. Ive done some edits and now have this code:

Code:
<?

$conn = mysql_connect("localhost","meat","gameguy");
$sdb = mysql_select_db("meat");

$query = "SELECT * FROM admin_users WHERE user='$user' AND pass='$pass'";
$sql = mysql_query($query);

if(!$sql){

echo "<font color=red>Failed to login!! Please try again.</font>";
include("login.php");
exit;
}

else if($sql) {

$time=date("h:ia d/j/y");

session_register('user');
$_SESSION['user'] = $user;

$query = "UPDATE admin_users SET admin_last='$time' WHERE user='$user' AND pass='$pass'";

$sql = mysql_query($query);
header("location: index.php");

}

?>


Ok, thats easy to understand, now this is the problem. ANYONE can login and they have the capability to mess around with the site (this admin area covers the whole site)

This is a serious problem, anyone know how I could fix this? Cookies is my next souce if someone cant help me out with this.

Reply With Quote
  #15  
Old August 12th, 2004, 06:14 AM
Chippo Chippo is offline
Contributing User
Tutorialized Newbie (0 - 499 posts)
 
Join Date: Mar 2004
Location: Stockport, UK
Posts: 462 Chippo New User: is a brand new recruit and a unknown entity at this point. 
Time spent in forums: 23 h 32 m 47 sec
Reputation Power: 0
Send a message via MSN to Chippo
ok I like it but where do you set your $user and $pass vars or are they inputs from a form? how do you store the pass in order for the login to be checked each time usin the password they have set?

Reply With Quote
Reply

Viewing: Tutorialized ForumsDesktop ProgrammingC and Cpp > Password Protection Question


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 

Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.

© 2003-2017 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap