Looks like you used to use
require("../includes/constants.php");
require("../includes/functions.php");
Are you sure you have the path correct?
Looks like you used to use
require("../includes/constants.php");
require("../includes/functions.php");
Are you sure you have the path correct?
well, i can only say you ve been blessed with very sharp eyes… this is what i got
array (size=1)
‘id’ => int 40
And to confirm, it is still showing the login page? Instead of the portfolio information?
yup, i just removed the dump and die functions and checked again…
Hmm… very odd.
Try replacing
// require authentication for most pages
if (!preg_match("{(?:login|logout|register)\\.php$}", $_SERVER["PHP_SELF"]))
{
if (empty($_SESSION["id"]))
{
redirect("login.php");
}
}
With
// require authentication for most pages
if (!preg_match("{(?:login|logout|register)\\.php$}", $_SERVER["PHP_SELF"]))
{
if (empty($_SESSION["id"]))
{
die("SESSION ID IS EMPTY");
redirect("login.php");
}
}
it now displays a blank page with this showing… “SESSION ID IS EMPTY”
Okay, so the var_dump shows id being a part of $_SESSION, but it is evaluated as empty… This is weird.
Okay, next change
// require authentication for most pages
if (!preg_match("{(?:login|logout|register)\\.php$}", $_SERVER["PHP_SELF"]))
{
if (empty($_SESSION["id"]))
{
var_dump($_SESSION);
die("SESSION ID IS EMPTY");
redirect("login.php");
}
}
whoa, i don’t quite well understand what’s going on and how you 're interperating what looks like nothing tasty to me to sensible information… , but i did the second change, and this is what i have now
array (size=1)
‘id’ => null
SESSION ID IS EMPTY
Interesting, this time the id is null… so loading the login.php page is correct.
Go through the login, pass, or reset pages and when it eventually redirects you back to index.php let me know what output you get.
you mean without the var_dump and die statements??
I’d keep those in if you can, if you can’t… then yes, go ahead and remove them.
well, i get this for localhost/index.php
array (size=0)
empty
SESSION ID IS EMPTY
and the normal displays for login.php, pass.ph, and reset.php, and finally when i entered passwords on reset.php (with the var-dumps) i got this
array (size=1)
‘id’ => null
SESSION ID IS EMPTY
can you show me your current reset.php file? I’m assuming it has a require(“…/includes/config.php”); in it and that is above the session usage.
well, i copied some of the contents of config.php as follows on top…
<?php
// display errors, warnings, and notices
ini_set("display_errors", true);
error_reporting(E_ALL);
// configuration
require("../includes/constants.php");
require("../includes/functions.php");
session_start();
// if form was submitted
if ($_SERVER["REQUEST_METHOD"] == "POST")
{
if (empty($_POST["password"]))
apologize("Please enter password.");
if ($_POST["password"] != $_POST["confirmation"])
apologize("Passwords do not match!");
$result = query("UPDATE users SET hash = ? WHERE id = ?", crypt($_POST["password"]), $_SESSION["resetmemberid"]);
unset($_SESSION["resetmemberid"]);
if($result===false)
{
apologize("Could not register. Please retry.");
}
else
{
$rows = query("SELECT id FROM users WHERE hash = ?", crypt($_POST["password"]));
$id = $rows[0]["id"];
// remember that user's now logged in by storing user's ID in session
$_SESSION["id"]= $rows[0]["id"];
// redirect to portfolio
redirect("index.php");
// require authentication for most pages
if (!preg_match("{(?:login|logout|register)\\.php$}", $_SERVER["PHP_SELF"]))
{
if (empty($_SESSION["id"]))
{
die("SESSION ID IS EMPTY");
redirect("login.php");
}
}
}
}
else
{
// else render form
render("reset_form.php", ["title" => "Register"]);
}
?>
Hello! you there?? i screwed up in my html validation from http://validator.w3.org/, it says
Line 46, Column 6: Stray end tag div.
</div>
Line 46, Column 6: Stray end tag div.
</div>
Line 47, Column 5: Start tag div seen in table.
<div>
Line 47, Column 5: Cannot recover after last error. Any further errors will be ignored.
<div>
can you please take a look??
<!DOCTYPE html>
<html>
<head>
<link href="css/bootstrap.css" rel="stylesheet"/>
<link href="css/bootstrap-responsive.css" rel="stylesheet"/>
<link href="css/styles.css" rel="stylesheet"/>
<title>C$50 Finance: Portfolio</title>
<script src="js/jquery-1.8.2.js"></script>
<script src="js/bootstrap.js"></script>
<script src="js/scripts.js"></script>
</head>
<body>
<div class="container-fluid">
<div id="top">
<a href="/"><img alt="C$50 Finance" src="img/logo.gif"/></a>
</div>
<div id="middle">
<div>
<table class="table table-striped">
<thead>
<tr>
<th>Symbol</th>
<th>Name</th>
<th>Shares</th>
<th>Price</th>
<th>TOTAL</th>
</tr> </thead>
<tbody>
</tbody>
</div>
<div> ////////////////////////////////////////////////////////////////////lLINE 46
<a href="quote.php">Quote</a> //////////////////////////////////////////LINE 47
<a href="buy.php">Buy</a>
<a href="sell.php">Sell</a>
<a href="history.php">History</a>
<a href="logout.php">Log Out</a>
</div>
</div>
<div id="bottom">
Copyright © John Harvard
</div>
</div>
</body>
</html>
You are missing your closing table tag (right after the closing </tbody> tag.
Thanks budd, all green… i was wondering if there are any websites out there, that display their php codes, or even java or html so that people can like learn from them, and build something similar??
You can always host it on SourceForge, GIT, CodePlex, and other repo related sites.
thanks, i knew of source forge, and i visited it once, but it looked more like a software website where people shared their softwares, but couldnt find any websites…
Yes, it is primarily used for sharing your code.