After I have logged in successfully to my 'login page', the 'members page' appears
and displays information, data regarding that member but show up only one post instead of 10?I think I have session problem here and redirection do not working correctly, can somone help me ?
login.php
Code: Select all
<?php
session_start();
include "connect.php";
if (isset($_POST['txtusername']) && isset($_POST['txtpassword'])) {
// check if the user id and password combination is correct
if ($_POST['txtusername'] == 'admin' && $_POST['txtpassword'] == 'admin') {
//$_SESSION['login'] = "Login";
$txtusername = $_SESSION["txtusername"];
$txtpassword = $_SESSION["txtpassword"];
// after login we move to the main page
header('Location: firstprint.php');
exit;
} else {
include "connect.php";
mysql_select_db("post_db")
or die ("Could not select database because ".mysql_error());
$q = "SELECT id FROM $table1 WHERE txtusername='$txtusername' and txtpassword='$txtpassword'";
$result = mysql_query($q)or die (mysql_error());
if (mysql_num_rows($result) > 0) {
$user = mysql_fetch_array($result);
$_SESSION["ID"] = $user["id"];
//echo "<p>The Current Session ID is:".$ID."</p>";
//echo "<p>SQL IS:".$q."</p>";
header("location:firstprint.php");
}
else {
echo "Wrong Username or Password";
}
firstprint.php
<?php
// Connects to your Database
session_start();
include "connect.php";
$ID = $_SESSION["ID"];
mysql_select_db("post_db")
or die ("Could not select database because ".mysql_error());
$data = mysql_query("SELECT * FROM textpost WHERE id='$ID'")
or die(mysql_error());
echo "<h3>"."Your recent blog post's"."<br/>"."</h3>";
echo "<table align='right'>";
echo "<tr>";
echo "<td>";
echo "Login Page <a href='loginpage.html'>Click Here.</a>";
echo "</td>";
echo "<tr>"."<td> <br> </td>"."</tr>";
echo "<td>";
echo " Add New Post Here <a href='http://localhost/Project/add_post.php'>Click Here.</a>";
echo "</td>";
echo "</tr>";
echo "</table>";
echo "<table border='0' >";
if (mysql_num_rows($data) > 0){
while($info = mysql_fetch_array( $data ))
{
echo "<tr>"."<td><b>ID:</b></td> <td>".$info['id'] . "</td>"."</tr>";
echo "<tr>"."<td><b>Title:</b></td> <td>".$info['title'] . "</td>"."</tr>";
echo "<tr>"."<td><b>Comment:</b></td> <td>".$info['comment'] . " </td>"."</tr>";
echo "<tr>"."<td><b>Authorname:</b></td> <td>".$info['authorname'] . " </td>"."</tr>";
echo "<tr>"."<td><b>Date:</b></td> <td>".$info['date'] . " </td>"."</tr>";
echo "<tr>"."<td> <br> </td>"."</tr>";
?>
<td bgcolor="#FFFFFF"><a href="delete_firstprint.php?id=<?PHP echo $info['id']; ?>">delete</a></td>
<?PHP
}
echo "</table>";
}else{
echo "no results";
}
?>