Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // Our database connection
- $mysqli = mysqli_connect("localhost", "root", null, "lesson_03_php");
- var_dump($_POST);
- $sql="INSERT into countries(
- name,
- description,
- population
- )values(
- ' {$_POST['name']}',
- '{$_POST['description']}',
- {$_POST['population']}
- )";
- //QUery our database providing our connection and our sql
- $res = mysqli_query($conn, $sql);
- //Perform some derpy error handling
- ?>
- <!DOCTYPE html>
- <head>
- <title>Adding Countries</title>
- </head>
- <body>
- <!-- The form for creating a new country -->
- <form action="<?php echo $_SERVER["PHP_SELF"] ?>" method="post">
- <div>
- <label>Country Name:</label>
- <input name="name">
- </div>
- <div>
- <label>Country Description:</label>
- <textarea name="description"></textarea>
- </div>
- <div>
- <label>Country Population:</label>
- <input name="population" type="number">
- </div>
- <button type="submit">Create</button>
- </form>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement