I tired what you said about the session stuff but its coming up with ERROR's currently my coding looks like this i cant get it to work:
index.php
PHP Code:
<!-- Link to CSS-->
<link rel="stylesheet" type="text/css" href= "CSS/default.css" title="Main">
<?php
$mysqli = mysqli_connect("localhost","root","","forum");
$query = "select * from users where username = '$_POST[username]' and password = '$_POST[password]'";
$result = mysqli_query($mysqli,$query);
$_SESSION['userID'] = $userID;
if (mysqli_num_rows($result) == 0)
{
echo "User Not Found";
include "index.html";
}
else
{
echo "<h3>User Logged in</h3>";
include "threads.php";
}
mysqli_close($mysqli);
?>
new_threads.php
PHP Code:
<!-- Link to CSS-->
<link rel="stylesheet" type="text/css" href= "CSS/default.css" title="Main">
<?php
session_start();
// connect to database
$mysqli = mysqli_connect("localhost", "root","","forum");
// php string query insert into table
$myquery = "insert into threads
values ('','{$_SESSION['userID']}','{$_POST['title']}','{$_POST['date']}'}";
// function which runs the myquery string
$result = mysqli_query($mysqli,$myquery);
// if's statments for inerting data into table
If ($result==true)
{
echo "New Thread Added";
include "threads.php";
}
else
{
echo "Corrupt Thread";
include "threads.php";
}
// close connection with database
mysqli_close ($mysqli);
?>
threads.php
PHP Code:
<!-- Link to CSS-->
<link rel="stylesheet" type="text/css" href= "CSS/default.css" title="Main">
<p>
Welcome to the threads Page!!!!!!!!!
</p>
To start a new thread fill in the details and...
<form name "input" action="new_threads.php?userId=<?php echo $userId; ?>" method="post"></p>
<input type="hidden" name="user_Id" size="25" value="<?php echo $userId; ?>"><br>
<input type="text" name="title" size="25" value="Topic Name"><br>
<input type="text" name="date" size="25" value="Topic Date"><br>
<p><input type="submit" value="Submit"></p>
</form>
<form name "input" action="index.html" method="post"></p>
<p><input type="submit" value="Back"></p>
</form>
<p>Click the "Submit" button to create a thread.</p>
<?php
$mysqli = mysqli_connect("localhost", "root","","forum");
$myquery = "select * from `threads`";
$result = mysqli_query($mysqli,$myquery);
echo "<table>";
while($record = mysqli_fetch_array($result,MYSQL_ASSOC))
{
$threadID = $record["threadID"];
$user_ID = $record["user_ID"];
$title = $record["title"];
$date = $record["date"];
echo "<tr>";
echo "<td>";
echo $threadID;
echo "</td>";
echo "<td>";
echo $user_ID;
echo "</td>";
echo "<td>";
echo "<a href=\"posts.php?threadId=" . $threadID . "\">$title</a>";
echo "</td>";
echo "<td>";
echo $date ;
echo "</td>";
echo "</tr>";
}
echo "</table>";
?>
Bookmarks