Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE HTML>
- <html>
- <center>
- <head>
- <title> Page Title</title>
- </head>
- <body>
- <?php
- // Username: bossmodeteehee
- // Password: bossmodeteehee
- // Username: jeffreyquade
- // Password: jeffreyquade
- $servername = "localhost";
- $username = "Jeffrey_Quade";
- $password = "aPassword";
- // trying to connect to the server
- try {
- $conn = new PDO("mysql:host=$servername;dbname=jquadecr_HomeWork5", $username, $password);
- // set the PDO error mode to exception
- $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
- echo "Connected successfully";
- }
- catch(PDOException $e)
- {
- echo "Connection failed: " . $e->getMessage();
- }
- ?>
- <!-- select category -->
- <form action=" Homework5.2.php" method="post">
- ONE:<input type="radio" name="ONE" value="ONE"> <br>
- TWO:<input type="radio" name="ONE" value="TWO"> <br>
- THREE:<input type="radio" name="ONE" value="THREE"> <br>
- <!-- setting the link -->
- Link to Image: <input type="text" name="Link"> <br>
- <!-- setting the category -->
- Description: <input type="text" name="Description"> <br>
- <input type="submit" name="submit" value="submit">
- </form>
- <?php
- $cat = $_POST["ONE"]; // setting cat to the chosen category
- $img = $_POST["Link"]; //same for the image
- $dsc = $_POST["Description"]; // and description
- // putting it all into the table
- $sql = 'INSERT INTO "Pictures" (Category, Link, Description) VALUES ($cat, $img, $dsc)';
- ?>
- </body>
- </center>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement