Computer Forums

Member Login

Remember Me? Sign Up! | Forgot Password
 
Slogan
 
Computer Forums > Programmers Lounge > Programming Discussions » (hopefully) the last of my php website troubles
Closed Thread
Old 11-30-2006, 04:44 AM   #1 (permalink)
 
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  
Old 12-01-2006, 05:31 AM   #2 (permalink)
 
Ultra Techie

Join Date: Sep 2005

Posts: 638

tommyboy123x is on a distinguished road

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
__________________

Some real (as in actual) surveys that pay money!
tommyboy123x 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