any chance someone can look at this for me please

This is a discussion on "any chance someone can look at this for me please" within the PHP Forum section. This forum, and the thread "any chance someone can look at this for me please are both part of the Program Your Website category.



Go Back   Webforumz.com > Main Forums > Program Your Website > PHP Forum

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Dec 7th, 2006, 11:02
Reputable Member
Join Date: May 2006
Location: Northampton, UK
Posts: 399
Thanks: 0
Thanked 0 Times in 0 Posts
any chance someone can look at this for me please

Ive got a little problem with my sessions, let me explain what im doing and maybe someone can see where im going wrong here..... as allways ... thanks in advance.

Ok, i have 3 pages .... login.php, checkuser.php & secretpage.php

basically, a user will fill in there username and password in login.php and then checkuser.php will make sure everythings in order, and then they should be allowed to veiew secretpage.php .... simple eh?

ok heres login.php, its actually a simple htm file, its only still got the php extension because i was playing with it earlier.

Code: Select all
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>

<body>
<form method="POST" action="checkuser.php">
  <input type="text" name="username" />
 User name 
 <p>
    <input type="text" name="password" />
  Password</p>
  <p>
    <input type="submit" name="Submit" value="Submit" />
  </p>
</form>
</body>
</html>
And heres checkuser.php

Code: Select all
<?php
session_start();
include("Vars.inc");


$connection=mysql_connect($host, $user, $passwd)
        or die ("Could not connect !");
$db = mysql_select_db($database, $connection)
        or die ("Could not connect to Database");

$username = $_POST['username'];
$password = $_POST['password'];
$pass = md5($password);

$query = "SELECT password FROM customer WHERE user_name='$username'";
$result = mysql_query($query)
        or die ("could not find user");
$row = mysql_fetch_array($result);

if ($pass == $row['password'] )
{
    session_register("auth");
    @$_SESSION['auth'] = "yes";
    echo "login successfull<br />";
}
else
{
    echo "invalid password<br />";
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>

<body>
<ul>
<li><a href="secretpage.php">secret page</a></li>
</ul>
</body>
</html>
Pretty straigh forward.... the above 2 files work perfectly, the problem comes when i want to access further secure pages, such as secretpage.php

heres secretpage.php at the momnent

Code: Select all
<?php
session_start();
if ( @$SESSION['auth'] != "yes" )
    {
        header("location: hacker.php");
        exit();
    }
else
    {
        echo "You are now logged in!";
    }
    
?>
<html>
<head><title>Secret Page </title></head>
<body>

This is my testing secret page.
</body></html>
At the moment all i can manage to do is get thrown out towards hacker.php .... which is clearly not what i want here.

I know its something to do with the way im handleing the sessions...... any idea's please??

Last edited by Accurax; Dec 7th, 2006 at 11:06.
Reply With Quote

  #2 (permalink)  
Old Dec 7th, 2006, 12:05
Reputable Member
Join Date: May 2006
Location: Northampton, UK
Posts: 399
Thanks: 0
Thanked 0 Times in 0 Posts
Re: any chance someone can look at this for me please

its ok i got it.... I missed a damn underscore.... lol
Reply With Quote
  #3 (permalink)  
Old Dec 7th, 2006, 23:14
JacobHaug's Avatar
SuperMember

SuperMember
Join Date: Dec 2005
Location: On Internet
Posts: 4,859
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to JacobHaug Send a message via MSN to JacobHaug
Re: any chance someone can look at this for me please

hahaha...they are really important...lol
Reply With Quote
  #4 (permalink)  
Old Dec 9th, 2006, 21:30
Ryan Fait's Avatar
SuperMember

SuperMember
Join Date: May 2006
Location: Las Vegas
Posts: 3,786
Thanks: 0
Thanked 0 Times in 0 Posts
Re: any chance someone can look at this for me please

I see that.
Reply With Quote
Reply

Tags
session

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

Similar Threads
Thread Thread Starter Forum Replies Last Post
50% transparent png with PHP... no chance? Lucleonhart PHP Forum 3 Feb 26th, 2008 20:59
Second Chance Sunday(Monday) acrikey Webforumz Cafe 10 May 30th, 2007 16:42


All times are GMT. The time now is 11:21.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

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