Computer ForumsComputers  

Go Back   Computer Forums > Programmers Lounge > Programming Discussions

Reply
 
LinkBack Thread Tools Display Modes
Old 11-30-2006, 03:44 AM   #1 (permalink)
Ultra Techie
 
Join Date: Sep 2005
Posts: 625
Send a message via AIM to tommyboy123x
Default (hopefully) the last of my php website troubles

so after hours of debugging i finally got all the stuff figured out, but I can't figure out how to correctly put in a PHP session!

here is the log-in page
PHP Code:
<?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 (
$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="signinprocess.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"); ?>
here is "signinprocess.php"

PHP Code:
<?php
session_start
();
$_SESSION["username"] = "$username";
$username $_POST['username'];
$password $_POST['password'];

// make mysql connection
mysql_connect("mysql79.secureserver.net""tguillea""******") or die(mysql_error());
mysql_select_db("tguillea") or die(mysql_error());

$query "SELECT * FROM hsmemberdb WHERE username='$username' and emailpass='$password'";

$result mysql_query($query);

if (
mysql_num_rows($result) != 1) {
    include(
"signin.php?error=invalid");
    exit();
    }else {
        
header('Location: members/index.php');
    }
?>
and here is the final "members page index"

PHP Code:
<?php
session_start
();
if (isset(
$_SESSION["username"]) == 1){
    
$username $_SESSION["username"];
    }else{
    
header ('Location: ../signin.php');
    }
include(
'head.html');
echo 
$_SESSION["username"];
include(
'font.html');
include(
'foot.html');
?>
This is my attempt to put in a session - however it does not echo the username at the index page - anyone know why?
__________________
Life is good with SparkCash =)
tommyboy123x is offline   Reply With Quote
Old 12-01-2006, 04:31 AM   #2 (permalink)
Ultra Techie
 
Join Date: Sep 2005
Posts: 625
Send a message via AIM to tommyboy123x
Default

btw i fixed that little error in the "signinprocess.php" - i moved the $_SESSION['username'] right above this

Code:
        header('Location: members/index.php');
but it still hasn't fixed it
__________________
Life is good with SparkCash =)
tommyboy123x is offline   Reply With Quote
Reply

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



All times are GMT -5. The time now is 01:47 PM.


Powered by vBulletin® Version 3.7.1
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.1.0