I'm a little unsure on how to connect all of my files together for this project. Basically I have a simple login screen which pulls the username and password from my registration table. Once they log in, I want them to be able to see a few random research papers that were assigned to them. I'll add the link in my database to the paper and then assign 2-3 papers for 2-3 users. However, currently when I log in, and click on the papers page, I'm getting the echo message that I'm not signed in. Here are my files. The first one is the login screen which then gives them 2 options. The first is to go back to the home page and the second is their page with the assigned research papers.
<?php
define('DB_NAME', 'conference');
define('DB_USER', 'root');
define('DB_PASSWORD', 'password');
define('DB_HOST', 'localhost');
$link = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
mysqli_set_charset($link, 'utf8');
if (!$link) {
die("Database connection failed: " . mysqli_error($link));
}
$username = mysqli_real_escape_string($link, $_POST['username']);
$password = mysqli_real_escape_string($link, $_POST['password']);
function SignIn($link) {
session_start();
if (!empty($_POST['username'])) {
$query = mysqli_query($link, "SELECT * FROM users where username = '$_POST[username]' AND password = '$_POST[password]'")or die(mysqli_error($link));
$row = mysqli_fetch_array($query) or die(mysqli_error($link));
if (!empty($row['username']) && !empty($row['password'])) {
$_SESSION['username'] = $row['password'];
echo "Welcome to your User Account for CSIT Conference. Click to go home: ";
echo '<a href="index.html"> Home Page </a>. ';
echo "Or here to go to your assigned papers: ";
echo '<a href="assigned.php"> Assigned Papers </a>. ';
} else {
echo "SORRY... YOU ENTERD WRONG ID AND PASSWORD... PLEASE RETRY...";
}
}
}
if (isset($_POST['submit'])) {
SignIn($link);
}
Then when they click "assigned papers" i want it to at least say their name for now and then eventually pull the name of each paper, but its' not even doing that. Here is that php file:
<?php
session_start();
if (isset($_SESSION['verified_user'])) {
echo "Hello, '$firstname', Here are your assigned papers: ";
$paper1;
$paper2;
}
else {
echo "You are not logged in and cannot see this page.";
}
?>
Lastly, here is the user sql table if that helps with anything. Also, please let me know if I can add any more info. I'm still learning all of this so anything I can do to clarify is no problem. Thank you very much for your help!
-- phpMyAdmin SQL Dump
-- version 4.4.14
-- http://www.phpmyadmin.net
--
-- Host: 127.0.0.1
-- Generation Time: Oct 26, 2015 at 02:49 AM
-- Server version: 5.6.26
-- PHP Version: 5.6.12
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;
--
-- Database: `conference`
--
-- --------------------------------------------------------
--
-- Table structure for table `users`
--
CREATE TABLE IF NOT EXISTS `users` (
`firstname` varchar(40) NOT NULL,
`lastname` varchar(40) NOT NULL,
`username` varchar(40) NOT NULL,
`password` varchar(40) NOT NULL,
`state` varchar(40) NOT NULL,
`city` varchar(40) NOT NULL,
`streetaddress` varchar(40) NOT NULL,
`zipcode` varchar(40) NOT NULL,
`phonenumber` varchar(40) NOT NULL,
`emailaddress` varchar(40) NOT NULL,
`email` tinyint(1) NOT NULL,
`help` tinyint(1) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
-- Dumping data for table `users`
--
INSERT INTO `users` (`firstname`, `lastname`, `username`, `password`, `state`, `city`, `streetaddress`, `zipcode`, `phonenumber`, `emailaddress`, `email`, `help`) VALUES
('Steve', 'Paul', 'root', 'root', 'ny', 'new york', '20 ridge road', '10990', '98493938383939', 'loucolu@gmail.com', 0, 0),
('test', 'test', 'test', 'test', 'test', 'test', 'test', 'test', 'test', 'test', 0, 0),
('gsdfgsdfgqsdfgsdfg', 'sdfasdf', 'asdfasdfsadf', 'asdfasdfasdfasdf', 'asdfasdfasdfsadfsadfsdf', 'asdfasdfasdfasdfsadf', 'asdfasdf', 'asdfasfsfsfsdfasdfsdf', 'asdfasdfasdfsd', 'asdfasdfsadf', 0, 0);
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;