Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- date_default_timezone_set('Asia/Tbilisi');
- $mysqli = new mysqli('localhost', 'root', '', 'zura');
- $mysqli->query('SET NAMES utf8');
- if ( isset($_POST['add']) ) {
- $name = trim($_POST['name']);
- $timestamp = date('Y-m-d H:i:s');
- $stmt = $mysqli->prepare("INSERT INTO test_table(name, date) VALUES (?, ?)");
- $stmt->bind_param('ss', $name, $timestamp);
- $stmt->execute();
- }
- ?>
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="utf-8">
- <title>Date Test Page</title>
- </head>
- <body>
- <table border="1">
- <thead>
- <tr>
- <th>ID</th>
- <th>Date</th>
- </tr>
- </thead>
- <tbody>
- <?php
- $result = $mysqli->query('SELECT * FROM test_table');
- while ($row = $result->fetch_array(MYSQL_ASSOC)) :
- ?>
- <tr>
- <td><?php echo $row['id']; ?></td>
- <td><?php echo $row['name']; ?></td>
- <td><?php echo $row['date']; ?></td>
- </tr>
- <?php endwhile; ?>
- </tbody>
- </table>
- <form action='' method='POST'>
- <input type="text" placeholder="Enter your name..." name="name">
- <input type="submit" value="Add Name With Current Time" name="add">
- </form>
- <?php echo (isset($timestamp) ? $timestamp : ''); ?>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement