(hopefully) the last of my php website troubles

Status
Not open for further replies.

tommyboy123x

Daemon Poster
Messages
654
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:
<?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:
<?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:
<?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?
 
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
 
Status
Not open for further replies.
Back
Top Bottom