Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if(session_status() == PHP_SESSION_NONE) {
- session_start();
- }
- /*Connect with the DB*/
- $servername = "localhost";
- $username = "root";
- $password = "";
- $dbname = "project";
- $conn = new mysqli($servername, $username, $password, $dbname);
- ?>
- <?php
- include('Conexion.php');
- ?>
- <form method="post" action="registerExercise.php">
- <div class="input-group">
- <label>Title</label>
- <input type="title" name="title" value="">
- </div>
- <div class="input-group">
- <label>Text</label>
- <input type="text" name="text" value="">
- </div>
- <div class="input-group">
- <button type="submit" class="btn" name="reg_exercise">Add exercise</button>
- </div>
- </form>
- <?php
- include('Conexion.php');
- // REGISTER USER
- if (isset($_POST['reg_exercise'])) {
- // receive all input values from the form
- $title = mysqli_real_escape_string($conn, $_POST['title']);
- $text = mysqli_real_escape_string($conn, $_POST['text']);
- if (empty($title)) { array_push($errors, "Title is required"); }
- if (empty($text)) { array_push($errors, "Text is required"); }
- $query = "INSERT INTO exercises (title, text, null, null, null, null, null, null, null)
- VALUES('$title', '$text', null, null, null, null, null, null, null)";
- mysqli_query($conn, $query);
- header('location: index.php');
- }
- ?>
Add Comment
Please, Sign In to add comment