Click to See Complete Forum and Search --> : help with Sessions and Password thing


Conor
04-28-2004, 02:27 PM
ok i have this code

<?php
include("header.php");
$passw="seltzer";
if($passw==$password)
{
$_SESSION['loggedin']=="1";
}
elseif($_SESSION['loggedin']=="1")
{
$un = "";
$pass = "";
$db = "";
$host = "localhost";

$sql = mysql_connect($host, $un, $pass) or die(mysql_error());
mysql_select_db($db, $sql) or die(mysql_error());
$query = "SELECT * FROM school ORDER BY `ID` DESC LIMIT 5";// this makes sure that the newest news is first
$results = mysql_query($query) or die(mysql_error());

echo'<div class="content">';

echo'<div class="top">Hw Entries</div>';
while ($row = mysql_fetch_row($results))
{
echo'<h3>'.$row[1].'</h3><br><p>'.nl2br($row[2]).'</p><br>Added on &nbsp;'.$row[3].'&nbsp;|<a class="menu" href="entry.php?ID='.$row[0].' ">Add/View Comment(s)</a><hr>';
}
}


else
{
echo"<div class='content'><div class='top'>Enter Pass</div><form action='index.php' method='POST'>Enter Password:<input type='password' name='password'><input type='submit' name='submit'></div>";
}


include("footer.php");
?>


I have this code but it doesnt work.

When i go to the page first it displayts the else statement but once hit submit it just displays a blank page. Shouldnt it display my content because $password is equal to $pass

O yeah and the else statement displays until i gett the pass correct.

Conor
04-28-2004, 04:45 PM
i also tried this with the same result


<?php
include("header.php");
$passw="seltzer";



if($_SESSION['loggedin']=="1")
{
$un = "";
$pass = "";
$db = "";
$host = "localhost";

$sql = mysql_connect($host, $un, $pass) or die(mysql_error());
mysql_select_db($db, $sql) or die(mysql_error());
$query = "SELECT * FROM school ORDER BY `ID` DESC LIMIT 5";// this makes sure that the newest news is first
$results = mysql_query($query) or die(mysql_error());

echo'<div class="content">';

echo'<div class="top">Hw Entries</div>';
while ($row = mysql_fetch_row($results))
{
echo'<h3>'.$row[1].'</h3><br><p>'.nl2br($row[2]).'</p><br>Added on &nbsp;'.$row[3].'&nbsp;|<a class="menu" href="entry.php?ID='.$row[0].' ">Add/View Comment(s)</a><hr>';
}
}


else
{
if($submit=="")
{
echo"<div class='content'><div class='top'>Enter Pass</div><form action='index.php' method='POST'>Enter Password:<input type='password' name='password'><input type='submit' name='submit'>";
if($password==$passw)
{
$_SESSION['loggedin']="1";
echo"Correct Password</div>";
}
}
}


include("footer.php");
?>