Computer Forums

Member Login

Remember Me? Sign Up! | Forgot Password
 
Slogan
 
Computer Forums > Programmers Lounge > Programming Discussions » A Really Easy Php Question
Closed Thread
Old 12-08-2006, 02:38 AM   #11 (permalink)
 
Ultra Techie

Join Date: Sep 2005

Posts: 638

tommyboy123x is on a distinguished road

Send a message via AIM to tommyboy123x
Default

i had originally had isset, but it had the same thing, it loads both the "signin.php" and the "index.php"

I think it is more of an issue with the index page because it is 'including' the auth.php page. If i JUST go to the auth page

PHP Code:
UPDATED CODE BELOW 
This script directs me to google.com, which it should if i have the cookie and my username is in the database... But here is the index.php page with the include(), which i think is giving me the errors

PHP Code:
UPDATED CODE BELOW 
So why will it ALWAYS load both pages (signin.php and index.php)

btw all the edits have been put in for this thread
__________________

Some real (as in actual) surveys that pay money!
tommyboy123x is offline  
Old 12-08-2006, 11:00 AM   #12 (permalink)
 
Newb Techie

Join Date: Dec 2004

Posts: 45

Babbage

Default

Just to make sure I understand what you are saying, are you saying that everytime you go to then index.php page, no matter if you have the cookies set or not, it will always go to signin.php?

Is there any php code in head.php?
Babbage is offline  
Old 12-08-2006, 05:51 PM   #13 (permalink)
 
Ultra Techie

Join Date: Sep 2005

Posts: 638

tommyboy123x is on a distinguished road

Send a message via AIM to tommyboy123x
Default

no it loads both pages... but the index page is on top of the sign in page
__________________

Some real (as in actual) surveys that pay money!
tommyboy123x is offline  
Old 12-08-2006, 05:56 PM   #14 (permalink)
 
Newb Techie

Join Date: Dec 2004

Posts: 45

Babbage

Default

Well, the only way I could see that happening is if your signin.php script calls index.php through an include() or require(). Can you post the code for signin.php?
Babbage is offline  
Old 12-08-2006, 06:51 PM   #15 (permalink)
 
Ultra Techie

Join Date: Sep 2005

Posts: 638

tommyboy123x is on a distinguished road

Send a message via AIM to tommyboy123x
Default

I always move the code to the bottom of the thread so that new people who try to help just look at it and say something someone else already did - just "so ya know"

I'm really stumped by this one - i just can't figure out what it is!

Here's signin.php

PHP Code:
<?php 
//signin.php
include("head.html"); ?>
</center></font>[/b]
<font size="3" color="red">
<?php
$error 
$_GET['error'];
$signin $_GET['signup'];

if (
$error == invalid){
    echo 
'Invalid password/username combination';
    }
if (
$error == sessionerror){
    echo 
'You are not authorized to view this information or your login information is not valid - Please try again';
    }
if (
$signin == true){
    echo 
'Congratulations!  You have successfully signed up!';
    }
?>
</font>[b]<font size="4"><center>
Sign-in 
<?php include("../../font.html"); ?>


Type in your login information.  If you do not yet have an account, please [url="signup.php"]request an invite[/url].


<form method="POST" action="process.php">
Username:

    <input type="text" name="username" size="25" maxlength="20">

Password:

    <input type="password" name="password" size="25" maxlength="20">

    <input type="submit" value="Sign In" name="submit"></p>
</form>

<?php include("foot.html"); ?>
PHP Code:
    <?php
    
//auth.php
    
$username $_COOKIE['user'];
    
$password $_COOKIE['pass'];

    if(empty(
$username) || empty($password)){
        
header('Location: ../signin.php?error=sessionerror');
        }


    
//connect to mysql

    
$hsmemberdb mysql_connect("**SERVER**""**USERNAME**""**PASSWORD**") or die(mysql_error());
    
mysql_select_db("**DATABASE**") or die(mysql_error());

    
$query "SELECT * FROM hsmemberdb WHERE username = '$username' and ********* = '$password'";
    
$result mysql_query($query);

    if (
mysql_num_rows($result) == 1) {
        
header('Location: h**p://www.google.com');  //edited this url because it was putting the <a> tag around it
        
exit();
        }else{
        
header('Location: ../signin.php?error=invalid');
        }
    
?>
PHP Code:
    <?php
    
//index.php
    
include('auth.php');  //THIS IS THE FILE FROM ABOVE
    
include('head.php');

    
//testing - to make sure the cookies were working
    
echo 'hello ' .$_COOKIE['user'];
    echo 
'
you have '
.$_COOKIE['invitekeys'].' invites left';
    echo 
'
you have shared '
.$_COOKIE['shared'].' files';
    echo 
'
you have downloaded '
.$_COOKIE['downloaded'].' files';
    
?>

__________________

Some real (as in actual) surveys that pay money!
tommyboy123x is offline  
Old 12-08-2006, 07:21 PM   #16 (permalink)
 
Newb Techie

Join Date: Dec 2004

Posts: 45

Babbage

Default

Well, your code looks like it should be alright to me.

Does it give you any errors when the page loads? Something maybe like "headers have already been modified" or similar?

One thing I did notice, however, is that your index.php includes (head.php) and the signin.php includes (head.html). Don't know if that would make any difference for you, however.
Babbage is offline  
Old 12-09-2006, 12:38 AM   #17 (permalink)
 
Ultra Techie

Join Date: Sep 2005

Posts: 638

tommyboy123x is on a distinguished road

Send a message via AIM to tommyboy123x
Default

the head.php is for the members area where it echos the invite codes, viewed, and shared documents - it has a slightly different layout and stuff. I'm going to try and put auth.php within head.php for a test... i'll post how it went

still does it... weirdest thing

but i've decided since the only time someone needs to be a registered user is when performing an action, such as viewing ("downloading") a document or sharing a document, so i'll just figure something out to do it when that occurs.

btw thanks for all the help so far, i noticed you joined about 2 years ago and have accumulated like 1/6 of your posts in this thread. Tech-forums "rediscovered"?
__________________

Some real (as in actual) surveys that pay money!
tommyboy123x is offline  
Old 12-09-2006, 09:40 PM   #18 (permalink)
 
Newb Techie

Join Date: Dec 2004

Posts: 45

Babbage

Default

Quote:
the head.php is for the members area where it echos the invite codes, viewed, and shared documents - it has a slightly different layout and stuff. I'm going to try and put auth.php within head.php for a test... i'll post how it went
Thats cool. Keep me posted, because I would really like to know what the heck is going on You never know when you will run into a problem like this in the future


Quote:
btw thanks for all the help so far, i noticed you joined about 2 years ago and have accumulated like 1/6 of your posts in this thread. Tech-forums "rediscovered"?
Hey thats no problem.

I wouldn't really say "rediscovered". I come here form time to time, just to see what kind of problems people are having, and if I can, I will try and help them. But when I see a lot of people posting "google search" as answers to serious questions, I get a little discouraged as to how well the forum community works together, so I kind of stray away. But, I still like to show up every now and then to help out.

I'd like to think that if I had a problem, someone would be able to help me out too
Babbage is offline  
Old 01-15-2007, 03:36 AM   #19 (permalink)
 
Ultra Techie

Join Date: Sep 2005

Posts: 638

tommyboy123x is on a distinguished road

Send a message via AIM to tommyboy123x
Default

you said you wanted me to tell you if I ever found the problem. One line

PHP Code:
session_start() 
when I did remember to put this in, I didn't put it on the pages I wanted to use a session on. So for example - If i used it, I would have to put it on the signinprocess.php AS WELL AS the index.php in the members page.

I kind of happened upon that and was estatic when i did

EDIT: also, there is no way [that i know of] to get session variables in an included file. You can do this by just changing it to a normal variable though which is what i did
__________________

Some real (as in actual) surveys that pay money!
tommyboy123x is offline  
Old 01-15-2007, 02:06 PM   #20 (permalink)
 
Newb Techie

Join Date: Dec 2004

Posts: 45

Babbage

Default

Glad to hear you were able to figure it out tommyboy123x!

Yeah, usually when I have to use sessions, I put the following in file (something like sessions.php), and just include that in all my files before anything else:

PHP Code:
<?php
  
/************************************
   *          Header Stuff            *
   ************************************/
     // This _must_ to be sent BEFORE any HTML
     
session_start();
     
header("Cache-control: private"); // IE 6 Fix.
?>

Quote:
EDIT: also, there is no way [that i know of] to get session variables in an included file. You can do this by just changing it to a normal variable though which is what i did
Did you try storing your information in the $_SESSION[" "] variable? This usually can store session specific information, and as long as you start the session you should be able to access them.
Babbage is offline  
 
Closed Thread

Thread Tools
Display Modes

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