Advertisement
Guest User

Untitled

a guest
Dec 13th, 2018
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.80 KB | None | 0 0
  1. <html>
  2. <body>
  3.  
  4. <p>
  5.  I only need the JW Pepper Link, so place it below.
  6.   </p>  
  7.  
  8. <form action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>" method="post">
  9. JW Pepper URL <input type="text" name="URL"><br>
  10. <input type="submit">
  11. </form>
  12.  
  13. <?php
  14. $servername = "localhost";
  15. $username = "Db User";
  16. $password = "Db Password";
  17. $dbname = "pepTest";
  18.  
  19. // Create connection
  20. $conn = new mysqli($servername, $username, $password, $dbname);
  21.  
  22. // Check connection
  23. if ($conn->connect_error) {
  24.     die("Connection failed: " . $conn->connect_error);
  25. }
  26. // prepare and bind
  27. //$stmt = $conn->prepare("INSERT INTO pepTest (URL) VALUES (?)");
  28. //$stmt->bind_param("s", $URL);  
  29.  
  30. // set parameters and execute
  31. $URL = $_POST["URL"];
  32.  
  33.  
  34.  
  35. if(isset($URL)){
  36.   $item = ".item#/";
  37.   $https = "https://www.jwpepper.com/";
  38.   $info1 = strpos($URL, $item);
  39.   $info2 = strpos($URL, $https);
  40.  
  41.   if($info1 !== false && $info2 !== false){
  42.     $doubleValue = $conn->query("select URL from pepTest where URL = '$URL'");
  43.    // $URL = $conn->query("insert into pepTest (URL) values ('$URL')");
  44.     //echo "Submit Successful <br>";
  45.     if($doubleValue->num_rows == 0){
  46.      $URL = $conn->query("insert into pepTest (URL) values ('$URL')");
  47.      echo "Submit Successful <br>";
  48.       echo "GOOD!";
  49.     }else{
  50.       echo "This already exists in the database! <br>";
  51.     }
  52.    
  53.   } else{
  54.     echo "Please enter a music item from JW Pepper <br>";
  55.   }
  56. }
  57.  
  58. $printDB = "SELECT * FROM pepTest";
  59. $result = $conn->query($printDB);
  60. echo "CURRENT DATABASE CONTENTS <br>";
  61. if ($result->num_rows > 0){
  62.   while ($row = $result->fetch_assoc()) {
  63.     echo "Song Name: " . $row["NAME"]. "     URL:" . $row["URL"] . "<br>" ;
  64.   }
  65. } else {
  66.   echo "No Results Displayed";
  67. }
  68.  
  69.  
  70. $stmt->close();
  71. $conn->close();
  72. ?>
  73.  
  74. </body>
  75. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement