-1
<?php

// Inialize session
session_start();
include('config.inc');
// Check, if username session is NOT set then this page will jump to login page
if (!isset($_SESSION['username'])) {
        header('Location: index.php');
}
?>
<html>

<head>
  <title>Secured Page</title>
</head>

<body>

<?php 
$result = mysql_query("SELECT user.password, data1.dob FROM user INNER JOIN data1 ON user.username = data1.username WHERE username = '" . $_SESSION['username'] . "'");

  echo "<table border='1'>
  <tr>
  <th>Name</th>
  <th>Message</th>
  </tr>";
  while ($row = mysql_fetch_array($result)) {
  echo "<tr>";
  echo "<td>" . $row['password'] . "</td>";
  echo "<td>" . $row['dob'] . "</td>";
  echo "</tr>";
  }
  echo "</table>";

?>
<p><a href="logout.php">Logout</a></p>

</body>

</html>

Edited by Dani: Formatting fixed

Votes + Comments
Unclear post. What is your actual problem.,=
3
Contributors
10
Replies
11
Views
6 Years
Discussion Span
Last Post by vibhaJ
Featured Replies
  • 1

    Try user.username in where condition. [CODE] $result = mysql_query("SELECT user.password, data1.dob FROM user INNER JOIN data1 ON user.username = data1.username WHERE user.username = '" . $_SESSION['username'] . "'"); [/CODE] Read More

0

I know its your first post, but at least should have sense how would people know your problem without describing.
And yeah have practice with code tag to post code.

0
<?php

// Inialize session
session_start();
include('config.inc');
// Check, if username session is NOT set then this page will jump to login page
if (!isset($_SESSION['username'])) {
header('Location: index.php');
}
?>
<html>

<head>
<title>Secured Page</title>
</head>

<body>

<?php
$result = mysql_query("SELECT user.password, data1.dob FROM user INNER JOIN data1 ON user.username = data1.username WHERE username = '" . $_SESSION['username'] . "'");

echo "<table border='1'>
<tr>
<th>Name</th>
<th>Message</th>
</tr>";
while ($row = mysql_fetch_array($result)) {
echo "<tr>";
echo "<td>" . $row['password'] . "</td>";
echo "<td>" . $row['dob'] . "</td>";
echo "</tr>";
}
echo "</table>";

?>
<p><a href="logout.php">Logout</a></p>

</body>

</html>
0

I have two MySQL table table "user" & "data1" i want to display data from both table,
user name is conman both table. if user one login then it should be display data for user one..........thanks in advance. please help me

0

I have two MySQL table table "user" & "data1" i want to display data from both table,
user name is conman both table. if user one login then it should be display data for user one..........thanks in advance. please help me

Now what is your output with this code?

0

This is the out put sir

Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\login\securedpage.php on line 27

1

Try user.username in where condition.

$result = mysql_query("SELECT user.password, data1.dob FROM user INNER JOIN data1 ON user.username = data1.username WHERE user.username = '" . $_SESSION['username'] . "'");
0

Thanks sir,
my prob. is solved ......!
thanks to daniweb, vibhadevit sir, & Karthik_pranas.

Thanks a lot.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.