if(!empty($def['id']))
<pre><html> <head> <title>My first PHP Website</title> </head> <?php include('functions.php'); session_start(); //starts the session if($_SESSION['user']){ // checks if the user is logged in } else{ header('location: index.php'); // redirects if user is not logged in } $user = $_SESSION['user']; //assigns user value ?> <body> <h2>Home Page</h2> <p>Hello <?php Print "$user"?>!</p> <a href="logout.php">Click here to go logout</a><br/><br/> <a href="home.php">Return to home page</a> <h2 align="center">Currently Selected</h2> <table border="1px" width="100%"> <tr> <th>Id</th> <th>Details</th> <th>Post Time</th> <th>Edit Time</th> <th>Public Post</th> </tr> <?php $id_exists = false; if(!empty($def['id'])) { $id_exists = true; $con = getDBConnection(); $id = $_GET['id']; $_SESSION['id'] = $id; $query = mysqli_query($con,"Select * from list"); $count = mysqli_num_rows($query); Print '<h2 align="center">There are ' . $count . 'rows'; if($count > 0) { while($row = mysqli_fetch_array($query)) { Print "<tr>"; Print '<td align="center">' . $row['id'] . "</td>"; Print '<td align="center">' . $row['details'] . "</td>"; Print '<td align="center">' . $row['date_posted'] . " - " . $row['time_posted']."</td>"; Print '<td align="center">' . $row['date_edited'] . " - " . $row['time_edited']."</td>"; Print '<td align="center">' . $row['public'] . "</td>"; Print "</tr>"; } } else { $id_exists = false; } } ?> </table> <br/> <?php if($id_exists) { Print ' <form action="edit.php" method="post"> Enter new detail: <input type="text" name="details"/><br/> public post? <input type="checkbox name="public[]" value="yes"/><br/> <input type="submit" value="Update List"/> </form> '; } else { Print '<h2 align="center">There is not data to be edited.</h2>'; } ?> </body> </html>
$def
if(!empty($_GET['id']))
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)