View Single Post
Old 11-30-2006, 04:44 AM   #1 (permalink)
tommyboy123x
 
Ultra Techie

Join Date: Sep 2005

Posts: 638

tommyboy123x is on a distinguished road

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?
__________________

Some real (as in actual) surveys that pay money!
tommyboy123x is offline