Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- <title>Super Dating</title>
- <link rel="stylesheet" type="text/css" href="style.css">
- </head>
- <body>
- <?php
- $servername = "localhost";
- $username = "root";
- $password = "";
- try {
- $conn = new PDO("mysql:host=$servername;dbname=super_dating", $username, $password);
- // set the PDO error mode to exception
- $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
- echo "Connected successfully";
- if(isset($_POST["submit"])) {
- //Editing profile settings
- $first_name = $_POST['first_name'];
- $last_name = $_POST['last_name'];
- $alias = $_POST['alias'];
- $description = $_POST['description'];
- $age = $_POST['age'];
- $location = $_POST['location'];
- $occupation = $_POST['occupation'];
- $power = $_POST['power'];
- $arch_enemy = $_POST['arch_enemy'];
- $insert = $conn->prepare("UPDATE `profile` SET first_name = '$first_name',
- last_name = '$last_name',
- alias = '$alias',
- description = '$description',
- age = '$age',
- location = '$location',
- occupation = '$occupation',
- power = '$power',
- arch_enemy = '$arch_enemy'
- WHERE id = '1'");
- $insert->execute();
- echo "Changes saved.";
- }
- if(isset($_POST["submit_comment"])) {
- //Comments section
- $comment_content = $_POST['comment'];
- $post_comment = $conn -> prepare("INSERT INTO `comments` (content)
- VALUES (:comment_content)");
- $post_comment -> bindParam(":comment_content", $comment_content);
- $post_comment -> execute();
- echo "Comment has been posted.";
- }
- if(isset($_POST["submit_message"])) {
- //Message section
- $message_content = $_POST['message'];
- $send_message = $conn -> prepare("INSERT INTO `messages` (content)
- VALUES (:message_content)");
- $send_message -> bindParam(":message_content", $message_content);
- $send_message -> execute();
- echo "Message has been sent.";
- }
- }
- catch(PDOException $e) {
- echo "Connection failed: " . $e->getMessage();
- }
- ?>
- <form method="post">
- <label>First name:</label>
- <input type="text" name="first_name" placeholder="First Name">
- <label>Last name:</label>
- <input type="text" name="last_name" placeholder="LastName">
- <label>Alias:</label>
- <input type="text" name="alias" placeholder="Alias">
- <label>Description:</label>
- <input type="text" name="description" placeholder="Description">
- <label>Age:</label>
- <input type="number" name="age" placeholder="Age">
- <label>Location:</label>
- <input type="text" name="location" placeholder="Location">
- <label>Occupation:</label>
- <input type="text" name="occupation" placeholder="Occupation">
- <label>Super powers:</label>
- <input type="text" name="power" placeholder="Powers">
- <label>Arch-enemy:</label>
- <input type="text" name="arch_enemy" placeholder="Arch-enemy">
- <input type="submit" name="submit" value="SAVE CHANGES">
- </form>
- <?php
- $stmt = $conn->query('SELECT content, time, sender FROM comments');
- foreach ($stmt as $row) {
- echo $row['content'];
- echo $row['time'];
- echo $row['sender'];
- ?>
- </br>
- <?php
- }
- ?>
- <form method="post">
- <label>Comment:</label>
- <textarea name="comment" placeholder="Your comment"></textarea>
- <input type="submit" name="submit_comment" value="POST">
- </form>
- <?php
- $stmt = $conn->query('SELECT content, time, sender FROM messages');
- foreach ($stmt as $row) {
- echo $row['content'];
- echo $row['time'];
- echo $row['sender'];
- ?>
- </br>
- <?php
- }
- ?>
- <form method="post">
- <label>Message:</label>
- <textarea name="message" placeholder="Your comment"></textarea>
- <input type="submit" name="submit_message" value="MESSAGE">
- </form>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement