PHP Protected access to pages within set sessions -
<?php ob_start(); session_start(); include 'connection.php'; $username = $_session['user']; ?> <!doctype html> <html lang="en"> <head> <title>home page</title> <meta charset="utf-8" /> <link href="../css/my_design.css" media="screen" rel="stylesheet" type="text/css" /> <link href="../css/homepage.css" media="screen" rel="stylesheet" type="text/css"/> <link href="../css/bootstrap.css" media="screen" rel="stylesheet" type="text/css"/> </head> <div id="wrapper"> <body> <!-- header row --> <div class="grid10 first"> <?php include 'header.php'; ?> </div> <!-- 2 column row - content , navigation columns --> <div class="grid10 first"> <div class="container"> <?php include 'navigation.php'; ?> </div> </div> <div class="grid10 first"> <div class="container" align="center"> <?php if (isset($_session["user"])) { echo "<table border='10' align = 'center' cellpadding='2' width = 600px height = 50px> <tr> <th>user id</th> <th>username</th> <th>password</th> <th>email</th> </tr>"; echo "you logged in " . $_session['user']; $query = "(select * users username = " . $username . ")"; $result = mysqli_query($connection, $query) or die("error in query : $query " . mysqli_error()); while ($row = mysqli_fetch_assoc( $result)) { echo "<tr>"; echo "<td>" . $row['userid'] . "</td>"; echo "<td>" . $row['username'] . "</td>"; echo "<td>" . $row['password'] . "</td>"; echo "<td>" . $row['email'] . "</td>"; echo "</tr>"; } echo "</br>hi: ".$row['userid']; } else { echo 'accessed denied'; } echo "</table>"; echo "</br>"; echo "</br>"; echo "</br>"; echo "</br>"; ?>
<div class="grid9 first"> <footer id="footer"> <?php include 'footer.php'; ?> </footer> </div> </body> </div>
everytime try keep getting message
warning: mysqli_error() expects 1 parameter, 0 given in /study/comp/c3358011/webpages/isd/assessment/pages/protectedpage.php on line 60 error in query : (select * users username = mantis)
try select query , replace query one--
$query = "select * users username = '".$username."'";
Comments
Post a Comment