Jump to content

Session echo


GameYin

Recommended Posts

Hello  ;)

Dunno if sessions are working for me.  I have session_start(); on both. Can someone help? I don't know if sessions are setting since my next code following this won't work.

http://www.phpfreaks.com/forums/index.php/topic,194777.0.html

Noone would respond there :(  :-\  ???

 

<?php
session_start();
include 'config.php';  
$user = $_POST['username'];
$pass = $_POST['password'];
$query = mysql_query("SELECT * FROM Users WHERE Username = '$user' AND Password = '$pass' LIMIT 1") or die(mysql_error());
$row = mysql_fetch_array($query);

if($user != "" && $pass != "" || mysql_num_rows($query) > 0 || $row['Activated'] > 0) {
$_SESSION["status"] = "Logged";
$_SESSION['username'] = $user;
$_SESSION['password'] = $pass;
header("Location: index.php");
exit;
}
else {
$_SESSION["status"] = "Not logged";
$_SESSION['username'] = Guest;
echo "Something went wrong";
}
?>

I have this on index.php to see if session is working. How would I go about echoing the session username?

 

<? if (empty($_SESSION['username'])) { ?>
blah ez
<? }else{ ?>
blah kewl
<? 
}
?>

Link to comment
https://forums.phpfreaks.com/topic/103463-session-echo/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.